简体   繁体   中英

Building Boost dynamically linkable gives linking error?

I am trying to build boost and generate dll's but whatever I have done did not solve the problem.

Here what I have got:

Creating library bin.v2\\libs\\thread\\build\\msvc-11.0\\dbg\\adrs-mdl-32\\async-excpt-on\\thrd-mlt\\boost_thread-vc110-mt-gd-1_53.lib and object bin.v2\\libs\\thread\\build\\msvc-11.0\\dbg\\adrs-mdl-32\\async-excpt-on\\thrd-mlt\\boost_thread-vc110-mt-gd-1_53.exp thread.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::greg_month(unsigned short)" (_ imp ??0greg_month@gregorian@boost@@QAE@G@Z) referenced in function "public: __thiscall boost::gregorian::date::date(enum boost::date_time::special_values)" (??0date@gregorian@boost@@QAE@W4special_values@date_time@2@@Z) thread.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::operator unsigned short(void)const " (_ imp ??Bgreg_month@gregorian@boost@@QBEGXZ) referenced in function __catch$?make_external_thread_data@?A0x9b8c45f0@boost@@YAXXZ$0 bin.v2\\libs\\thread\\build\\msvc-11.0\\dbg\\adrs-mdl-32\\async-excpt-on\\thrd-mlt\\boost_ thread-vc110-mt-gd-1_53.dll : fatal error LNK1120: 2 unresolved externals

Here some information about the setup:

OS: W7 x64

Command to build:

b2 -j%NUMBER_OF_PROCESSORS% --abbreviate-paths toolset=msvc-11.0 define=_SECURE_SCL=0 define=_CRT_SECURE_NO_DEPRECATE define=_CRT_SECURE_NO_WARNINGS --without-mpi address-model=32 variant=debug install link=shared runtime-link=shared threading=multi asynch-exceptions=on exception-handling=on extern-c-nothrow=off --prefix=..\\boost cd ..

I have CYGWin installed to the computer.

Here what I have tried till now;

*I have tried to build it in 32 bit command window (I am using jenkins to build boost)

*I wrote #define BOOST_ALL_DYN_LINK in the boost config/user.hpp

*I wrote #define BOOST_ALL_NO_LIB in the boost config/user.hpp

Is there anyone who experienced such a problem before? I really could not find anything in anywhere?


EDIT:

There is an update about my problem. I am able to build it for release. Only thing that I have changed is here:

b2 -j%NUMBER_OF_PROCESSORS% --abbreviate-paths toolset=msvc-11.0 define=_SECURE_SCL=0 define=_CRT_SECURE_NO_DEPRECATE define=_CRT_SECURE_NO_WARNINGS --without-mpi address-model=32 variant=release install link=shared runtime-link=shared threading=multi asynch-exceptions=on exception-handling=on extern-c-nothrow=off --prefix=..\\boost cd ..

what could be the problem? How can I solve it?

Thanks in advance for any suggestion.

Actually I have found the solution:

The way I am using bjam is correct and enough to build boost dynamically. In that stage, I should not define anything. After compilation I change user.hpp and #define BOOST_ALL_DYN_LINK. This way my own projects (which are using boost) will understand boost is dynamic. That is the way how boost should be built.

That seems the best way because boost automatically decode necessary libs and dlls as expected and works well.

I see that there are lot of manual steps involved in achieving a successful boost build. Just in case you don't want to go through these manual steps and avoid overheads try BlueGo , provided that you want to use MSVC toolset. BlueGo allows to configure 32/64 bit, Debug/Release modes among other things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM