Boost logo

Boost-Build :

Subject: [Boost-build] Problem with resource files on Ubuntu
From: Ian Emmons (iemmons_at_[hidden])
Date: 2010-08-02 12:40:16

I am trying to build a shared library on several platforms (Windows, Macintosh, and Ubuntu Linux), and in both 32- and 64-bits (universal binaries on Mac). This works well on Windows and Mac, but I am having trouble with Ubuntu. I am running Ubuntu Linux 10.04, 64-bit, with the Boost.Build that is bundled in Boost 1.43.0 and bjam 3.1.18. The 64-bit build works fine, but cross-compiling for 32-bits fails on the resource file, Version.res. The output of bjam is shown below (abbreviated a bit by removing most of the .o's from the link command).

I've tried digging into the Boost.Build sources to find the problem, but unfortunately I am not expert enough to decode exactly what's going on. It appears that on non-Windows platforms, a .res target causes an invocation of the assembler to create an empty .o, thus effectively making the .res file into a no-op. However, when cross-compiling the appropriate options (in this case "--32" or "--64") are not added to the assembler's command line, and so it compiles a native .o that then fails to link with the .o's that came from the C++ compiler.

I'm not sure why Boost.Build doesn't just invoke the C++ compiler on an empty .cpp file to accomplish the same thing. That would ensure compatibility of the .o's without any extra work to get the command line options right.

Any ideas on how I can fix (or work around) this issue?

Thanks in advance,


P.S.: When I build a .res file on Macintosh (using "architecture=combined address-model=32_64" to get universal binaries), the link command generates innocuous warnings because the "empty" .o resulting from the .res file has only the one architecture in it. I was able to produce a universal .o manually with the following commands:

 touch empty.cpp
 g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64 -o empty.o -c empty.cpp

Boost.Build links this file into my universal binary without any warnings. (On Snow Leopard, of course, we don't want the "-arch ppc64" option, but that seems to be correctly handled elsewhere in Boost.Build.)

========================================= ../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/
/usr/bin/ld: i386:x86-64 architecture of input file `../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/Version_res.o' is incompatible with i386 output
collect2: ld returned 1 exit status

  "g++" -L"/usr/local/BerkeleyDB.5.0/32/lib" -o "../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/" -Wl,-h -Wl, -shared -Wl,--start-group "../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/Config.o" <<snip>> "../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/Version_res.o" -Wl,-Bstatic -Wl,-Bdynamic -ldb -lrt -Wl,--end-group -pthread -m32

...failed ../../target/bin/native/Parliament/KbCore/gcc-4.4/release/address-model-32/threading-multi/
...failed updating 1 target...
...updated 1 target...

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at