Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: lirong on May 28, 2007, 04:48:12 am

Title: How to link with platform dependent libraries (Different name)?
Post by: lirong on May 28, 2007, 04:48:12 am
Hi,
I need to link my application with boost c++ libraries.  On Linux, I need to add "boost_date_time.a", but on Windows, it is some thing like this "boost_date_time-mgw-mt-d-1_33_1.lib".  How can I solve this problem?

TIA
Title: Re: How to link with platform dependent libraries (Different name)?
Post by: kelo81 on May 28, 2007, 01:19:56 pm
Hi, you may create two different targets for the same project, something like "Win32" and "linux", and then you may add the libs to each target.
Title: Re: How to link with platform dependent libraries (Different name)?
Post by: Deschamps on May 28, 2007, 02:08:05 pm
You can also build your boost libraries (see documentation) with the --layout=system parameter for a generic naming without versions nor compilers "build info", so you'll have the same names in Linux or Windows platforms. For instance:

Code
C:\Devtools\boost_1_34_0\libs\date_time\build>bjam --toolset=gcc release --without-python --layout=system
Building Boost.Regex with the optional Unicode/ICU support disabled.
Please refer to the Boost.Regex documentation for more information
(don't panic: this is a strictly optional feature).
...patience...
...found 436 targets...
...updating 4 targets...
gcc.compile.c++ ..\..\..\bin.v2\libs\date_time\build\gcc-mingw-3.4.5\release\greg_month.o
gcc.compile.c++ ..\..\..\bin.v2\libs\date_time\build\gcc-mingw-3.4.5\release\greg_weekday.o
gcc.compile.c++ ..\..\..\bin.v2\libs\date_time\build\gcc-mingw-3.4.5\release\date_generators.o
gcc.link.dll ..\..\..\bin.v2\libs\date_time\build\gcc-mingw-3.4.5\release\boost_date_time.a ..\..\..\bin.v2 \libs\date_time\build\gcc-mingw-3.4.5\release\boost_date_time.dll
Creating library file: ..\..\..\bin.v2\libs\date_time\build\gcc-mingw-3.4.5\release\boost_date_time.a
...updated 4 targets...

C:\Devtools\boost_1_34_0\libs\date_time\build>