Boost logo

Boost Users :

Subject: Re: [Boost-users] [Regex] Can't create dylib that links regex statically
From: Rush Manbert (rush_at_[hidden])
Date: 2010-12-17 11:19:28


On Dec 16, 2010, at 2:21 PM, Marcos Pearson wrote:

> Hi there,
>
> I'm hoping someone can give me some hints on what I'm doing wrong. I'm trying to create a library that uses regex and has no external dependencies. My understanding is that I need to compile boost to be static and link static at runtime. My project is multi-platform, but I'm currently working on OSX 10.6.5.
>
> To build boost, I'm using the following command:
>
> sudo ./bjam link=static threading=multi runtime-link=static architecture=combined address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 install
>
> In Xcode, I've included the produced library, libboost_regex.a, in my Xcode project. I compile my dylib without errors or warning. However, I'm unable to load it. Checking the dependencies, my library seems to want the libboost_regex.dylib. Why?
>
> $ otool -L libglobalkvp.dylib
> libglobalkvp.dylib:
> /usr/local/lib/libglobalkvp.dylib (compatibility version 1.0.0, current version 1.0.0)
> /Users/marcospearson/Library/Frameworks/iqvectorsdk.framework/Versions/A/iqvectorsdk (compatibility version 1.0.0, current version 1.0.0)
> libboost_regex.dylib (compatibility version 0.0.0, current version 0.0.0)
> /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
> /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
>
> I've built, and re-build the boost libraries more times that I can remember and have read post after post, but haven't been able to figure out a solution. Any help would be appreciated.

Hi Marcos,

You can certainly do this. We do.

How do you link the regex library?

We use -lboost_regex.a in Other Linker Flags and specify the path for the library in Library Search Paths. The other way that I know of to get exactly the library you want, without any funny business because of how Xcode prefers dylibs to static libs, is to add the fully qualified path to the static library to your Other Linker Flags. (Or a relative path from $(SRCROOT), which works out better.)

If I were to guess, I would say that you have the dylib version of the regex library installed alongside your static lib, or in one of the places that is automatically searched. Xcode will link against a dylib in preference to a static lib of the same name.

Best regards,
Rush



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net