Boost logo

Boost-Build :

Subject: Re: [Boost-build] statically link project with Boost libs in Cygwin/msvc
From: Vladimir Prus (ghost_at_[hidden])
Date: 2009-06-12 04:13:18


On Friday 12 June 2009 Andrej van der Zee wrote:

>
> Hi,
>
> Thanks for your quick reply, as always.
>
> Below the Jamfile for my executable and the ouput of bjam -d2.
> On Linux it statically links as I expect. On Cygwin/Windows/msvc
> it holds it dependencies on the boost libs. But I am not sure what
> to expect, since I am not so proficient on Windows.
>
> Thank you,
> Andrej
>
>
> $ cat Jamfile
> project : requirements
> <os>CYGWIN:<define>_WIN32_WINNT=0x0501
> <os>CYGWIN:<library-path>/usr/local/lib
> ;
>
> exe cap2net
> : [ glob *.cpp ]
> /site-config//boost_regex
> /site-config//boost_serialization
> /site-config//boost_date_time
> : <link>static
> : <define>BOOST_REGEX_RECURSIVE
> ;
>
> install $(INSTALL_PATH)/bin : cap2net ;
>
> $ bjam -d2
> ...patience...
> ...found 1196 targets...
> ...updating 2 targets...
>
> file bin\msvc-9.0\debug\link-static\threading-multi\cap2net.exe.rsp
>
> "bin/msvc-9.0/debug/link-static/threading-multi/main.obj"
>
> "boost_regex-vc90-mt-gd-1_38.lib"

This is not static library. It is import library for DLL, therefore it's
natural that your library links to DLL. The static library would be named

   "libboost_regex-vc90-mt-gd-1_38.lib"

I think the declarations in site-config have to be appropriately modified. E.g:

        searched-lib boost_regex:
          : <link>shared:<name>boost_regex-vc90-mt-gd-1_38
            <link>static:<name>libboost_regex-vc90-mt-gd-1_38
          ;

Note that using <name> conditionally as above requires that you use shared-lib as
opposed to lib, as otherwise auto-detection of 'this is actually searched lib'
might not work. 'searched-lib' is the recommended spelling anyway now.

Does this help?

- Volodya


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk