15
votes

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.

3
You can suppress user.hpp with BOOST_NO_USER_CONFIG: groups.google.com/forum/#!topic/boost-list/OSkv0cKjpVMfatihk
@thomas Thank you for your comment. Actually I think I need #define BOOST_ALL_DYN_LINK definition so I added it to the user.hpp as my configuration. That way I define BOOST_ALL_DYN_LINK and if you read the comment above that it seems necessary. By default I think user.hpp is not supressed, right?meakgoz
Did you try including #define BOOST_ALL_DYN_LINK directly into date_time/compiler_config.hpp? This is probably a bad idea, but BOOST_DATE_TIME_DECL seems to be defined there.B. M. Knecht
thank you for all answers. I think I have found the solution and write it down but I should say that I get inspiration from your comments. @thomas sorry if you already meant the answer and I cannot understand correctly.meakgoz

3 Answers

2
votes

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.

1
votes

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.

0
votes

I've met this issue once again. Previous time I was using boost 1.54. Now - boost 1.71. I think that the real reason is that boost::thread dependencies list lacks boost::date_time. What worked for me for both version, was adding the following lines to the bottom of the requirements rule in libs/thread/build/Jamfile.v2:

if <target-os>windows in $(properties)
{
    result += <define>BOOST_THREAD_USES_DATE_TIME ;
    result += <library>/boost/date_time//boost_date_time ;  
}

I've created an issue on Github, let's see.