[build] Library suffix on mingw/win32
I have used boost for some time on windows with msvc, but I am trying to install & use it with mingw-g++. I'm no gcc expert, but it seems that ld requires specific extensions for libraries, and bjam is not generating the right ones. In particular, under mingw, the flag -lboost_unit_test_framework Will match boost_unit_test_framework.lib (the import library for the dll) Or libboost_unit_test_framework.a But NOT libboost_unit_test_framework.lib Which is what bjam produces. Here is an approach that WONT work: Using -llibboost_unit_test_framework Or -llibboost_unit_test_framework.lib Fails because the leading 'lib' is automatically stripped out by ld. As a solution I just renamed all lib*.lib files to lib*.a, but something seems basically wrong with the situation. I don't know WHY bjam used a '.lib' suffix, since I built the libraries using gcc. The static libraries I generate from gcc should be linkable from gcc... I use mingw + msys to build boost as follows: 1) I installed MinGW Automated Installer, MingW GCC 4.3.0, and then MSYS via its installer. - this creates C:\MingW and C:\msys\1.0. The gcc-4.3.0 files are extraced into C:\mingw 2) I open the MSYS shell by running msys.bat 3) I fetch boost/trunk into my home directory using svn. 4) I run tools/jam/build_dist.sh to create bjam 5) I copy bjam.exe to /mingw/bin 6) from within the msys shell, I run bjam --toolset=gcc --layout=system --build-type=complete --prefix=/mingw When I am done, under /mingw/lib I have files with names like: boost_*.dll boost_*.lib libboost_*.lib In particular, the static libraries have a '.lib' suffix. I have googled and searched the boost site, and I can find issues related to mingw/etc but nobody else seems to have _this_ problem. Is there something I am just doing wrong here? BTW: --toolset=mingw failed to find the mingw toolset, but when I build with gcc is seems to know what to do. Thanks, --John Femiani
John Femiani wrote:
I have used boost for some time on windows with msvc, but I am trying to install & use it with mingw-g++. I'm no gcc expert, but it seems that ld requires specific extensions for libraries, and bjam is not generating the right ones.
In particular, under mingw, the flag -lboost_unit_test_framework Will match boost_unit_test_framework.lib (the import library for the dll) Or libboost_unit_test_framework.a
Use -llibboost_unit_test_framework
When I am done, under /mingw/lib I have files with names like: boost_*.dll boost_*.lib libboost_*.lib In particular, the static libraries have a '.lib' suffix.
As you see, the unique quirk of Windows is that you have two kinds of static libraries -- import libs for dlls, and really static libraries. To grab import libs, use -lboost-* To grab real static libs, use: -llibboost-*
BTW: --toolset=mingw failed to find the mingw toolset, but when I build with gcc is seems to know what to do.
This is as expected. The compiler binary is called "g++", so why do you expect "toolset=mingw" to be used? - Volodya
on Sun Jul 06 2008, Vladimir Prus
John Femiani wrote:
I have used boost for some time on windows with msvc, ...
BTW: --toolset=mingw failed to find the mingw toolset, but when I build with gcc is seems to know what to do.
This is as expected. The compiler binary is called "g++", so why do you expect "toolset=mingw" to be used?
Maybe because he has been using boost for some time? We used to have a mingw toolset, IIRC. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
Dave Abrahams wrote:
John Femiani wrote:
I have used boost for some time on windows with msvc, ...
BTW: --toolset=mingw failed to find the mingw toolset, but when I build with gcc is seems to know what to do.
This is as expected. The compiler binary is called "g++", so why do you expect "toolset=mingw" to be used?
Maybe because he has been using boost for some time? We used to have a mingw toolset, IIRC.
Yes, I once succeeded with a 'mingw' toolset, but that was an earlier version. IIRC, it generated '.a' files back then, but I am not sure. Also when I googled for help I found the 'mingw' tool discussed, and if I don't use 'layout=system' the libraries are decorated with 'mgw4.3', which is ussually a tool name. -- John
Volodya wrote:
Use -llibboost_unit_test_framework
That was the second thing I tried :) Actually, I found out that the build tool I was using (scons) stripped the 'lib' out before passing the argument to g++. Frankly I am not sure where the issue should be discussed, maybe both in boost and scons mailing lists. It seams to me that the extension boost produces _should_ be '.a'. Msvc can't link with a mingw archive can it? I mean, msvc usually can't even link with its own .lib files unless the same runtime libraries are used, and I think I read that mingw mangles names differently. The import libs may be different, and _perhaps_ should have a .lib extension since I think they are usable from msvc, but shouldn't the static libraries have a '.a' extension? Didn't they used to, or am I just remembering things wrong? I will also post to the scons mailing list to find out why the leading 'lib' is stripped. Thanks Volodya, --John
participants (3)
-
David Abrahams
-
John Femiani
-
Vladimir Prus