简体   繁体   English

构建Boost动态链接会产生链接错误吗?

[英]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. 我正在尝试构建boost并生成dll,但无论我做了什么都没有解决问题。

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_ 创建库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和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:错误LNK2019:未解析的外部符号“__declspec(dllimport)public:__ thiscall boost :: gregorian :: greg_month :: greg_month(unsigned short)”(_ imp ?? 0greg_month @ gregorian @ boost @@ QAE @ G @ Z)在函数“public:__thiscall boost: :gregorian :: date :: date(enum boost :: date_time :: special_values)“(?? 0date @ gregorian @ boost @@ QAE @ W4special_values @ date_time @ 2 @@ Z)thread.obj:错误LNK2019:未解析的外部符号“__declspec(dllimport)public:__ thiscall boost :: gregorian :: greg_month :: operator unsigned short(void)const”(_ imp ?? Bgreg_month @ggorgorian @ boost @@ QBEGXZ)函数__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 thread-vc110-mt-gd-1_53.dll:致命错误LNK1120:2个未解析的外部

Here some information about the setup: 这里有一些关于设置的信息:

OS: W7 x64 操作系统: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 .. b2 -j%NUMBER_OF_PROCESSORS% - 简称路径工具集= 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. 我已将CYGWin安装到计算机上。

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) *我试图在32位命令窗口中构建它(我使用jenkins来构建boost)

*I wrote #define BOOST_ALL_DYN_LINK in the boost config/user.hpp *我在boost config / user.hpp中写了#define BOOST_ALL_DYN_LINK

*I wrote #define BOOST_ALL_NO_LIB in the boost config/user.hpp *我在boost config / user.hpp中写了#define BOOST_ALL_NO_LIB

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 .. 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. 我使用bjam的方式是正确的,足以动态地构建boost。 In that stage, I should not define anything. 在那个阶段,我不应该定义任何东西。 After compilation I change user.hpp and #define BOOST_ALL_DYN_LINK. 编译后,我更改了user.hpp和#define BOOST_ALL_DYN_LINK。 This way my own projects (which are using boost) will understand boost is dynamic. 这样我自己的项目(使用boost)将理解提升是动态的。 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. 这似乎是最好的方法,因为boost会按预期自动解码必要的lib和dll并且运行良好。

I see that there are lot of manual steps involved in achieving a successful boost build. 我看到实现成功的boost构建需要很多手动步骤。 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 ,前提是您要使用MSVC工具集。 BlueGo allows to configure 32/64 bit, Debug/Release modes among other things. BlueGo允许配置32/64位,调试/释放模式等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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