I'm working a patch-set to compile
dpkg and APT onto Cygwin. I've almost got everything working, but I'm encountering some weird behavior with
g++ that I can't explain.
APT's stock Makefile uses some fancy wrapping around a pretty standard
.a flow for support libraries, which are then linked in with the main code. It works great under Linux. Under Cygwin, however, the linker stage, using slightly different commands, fails in a way that I don't understand.
Why is it that
g++ -g -O2 \ -L../build/bin \ -o ../build/bin/apt \ ../build/obj/cmdline/apt.o \ ../build/obj/apt-pkg/*.o \ ← (This is different.) -lapt-private -lbz2 -liconv -lintl -llzma -lz
works on my system, but
ar rcs ../build/bin/libapt-pkg.a ../build/obj/apt-pkg/*.o ← (This is different.) g++ -g -O2 \ -L../build/bin \ -o ../build/bin/apt \ ../build/obj/cmdline/apt.o \ -lapt-pkg \ ← (This is different.) -lapt-private -lbz2 -liconv -lintl -llzma -lz
doesn't? When I run the second one,
libapt-pkg.a builds OK, but the
g++ step produces errors of the form:
$ g++ -g -O2 -L../build/bin -o ../build/bin/apt ../build/obj/cmdline/apt.o -lapt-pkg -lapt-private -lbz2 -liconv -lintl -llzma -lz 2>&1 | head ../build/bin/libapt-private.a(private-upgrade.o): In function `CacheFile': ./apt/apt-private/../build/include/apt-private/private-cachefile.h:47: undefined reference to `pkgCacheFile::pkgCacheFile()' ./apt/apt-private/../build/include/apt-private/private-cachefile.h:47:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `pkgCacheFile::pkgCacheFile()'
Shouldn't the two command sequences shown above be functionally equivalent? What's the difference?