Static linking issues with custom library names

Hi all.
I've built a static library that references boost threads, conditions and
ptime. All the libraries were build with the following command "bjam
--layout=system link=static release debug", then renamed to something more
generic eg. boost_thread-mt.lib for the multi-threaded release version of
the thread library. Now I know I did get the static libraries and not the
DLL bridges because it was originally named libboost_thread-mt.lib.
Actually I also used the --buildid command to add something other than
-1_35, but I don't think that really matters. Anyway, the Win32 version of
my project is built using VS2008, so I have a top level include file that
defines BOOST_ALL_NO_LIB to prevent auto-linking. I then explicitly link
the libraries that I need and build my project library. I assume it's
actually linking everything in successfully since the output lib is vastly
larger when I link the libs than when I don't.
Now the real problem comes when I try to link to this library in my test
application. I've switched up whether it is the lib or the application that
defines BOOST_ALL_NO_LIB, and who actually links to the libraries etc. I've
also made sure that they're all using the same run-time build settings eg.
/MTd for both my lib and app, which would link to the -mt-gd version of the
boost libraries. No matter what I do, I get a bunch of warnings about using
locally defined symbols (changing which one links the libraries just changes
whether the warning originates from my lib or boost's) and a few unresolved
externals. They look something like this:
Common.lib(thread.obj) : warning LNK4217: locally defined symbol
??0id@locale@std@@QAE@I@Z (public: __thiscall std::locale::id::id(unsigned
int)) imported in function "void __cdecl `dynamic initializer for 'public:
static class std::locale::id boost::date_time::date_facet

Darren Mason wrote:
If I'm not mistaken, LNK4217 means that the linker believes the symbol is local, but it's using a different calling convention, almost like it thinks it's importing from a DLL. I could suppress those by compiling against the Common Language Runtime, but somehow I think that I'm seeing these might be the root of my problem. Any thoughts?
What compiler options are you building your application with? It looks like Boost was built against the DLL C++ runtime library, but that your application is built against the static C++ runtime? Note that just because you used the static Boost library versions, there are still 6 C++ runtime variants of these possible. HTH, John.

Wow, can't believe I missed that one. Now I'm just embarrassed. Thanks John, that really helped me. After doing a little research, I came across the runtime-link=static bjam parameter and that fixed pretty much everything I was seeing. Thanks again, Darren
participants (2)
-
Darren Mason
-
John Maddock