Linking against 32 bit boost libraries

时间:2017-06-12 17:03:49

标签: c++ visual-studio boost static-linking

I'm trying to link my project against a couple of boost libraries and I ran into a 32 vs 64 bit problem.

I'm using Visual Studio 2015. I added path to the built boost libraries to VC++ Directories.

Here's the output I get:

2>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach@thread@boost@@QAEXXZ)
2>main.obj : error LNK2001: unresolved external symbol "private: bool __thiscall boost::thread::start_thread_noexcept(void)" (?start_thread_noexcept@thread@boost@@AAE_NXZ)
2>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)
2>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)
2>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base@detail@boost@@UAE@XZ)

I'm building boost using bootstrap like this:

b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage32

While searching for the solution I opened libboost_thread-vc140-mt-1_64.lib with a text editor and found functions that linker can't find to look like this ?detach@thread@boost@@QEAAXXZ

Some sources explain that QEAAXXZ is a name of a 64-bit compiled function. My linker though expects QAEXXZ (32-bit) as you can see from the output.

Am I building boost correctly for a 32-bit application? If so, why can't my application link against it?

0 个答案:

没有答案