【问题标题】:Building Boost dynamically linkable gives linking error?构建 Boost 动态可链接会导致链接错误?
【发布时间】:2014-02-05 13:24:45
【问题描述】:

我正在尝试构建 boost 并生成 dll,但我所做的一切都没有解决问题。

这是我得到的:

创建库 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 和对象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@日期时间@2@@Z) thread.obj:错误 LNK2019:未解析的外部符号“__declspec(dllimport) public: __thiscall boost::gregorian::greg_month::operator unsigned short(void)const” (_imp??Bgreg_month@gregorian @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:致命错误 LNK1120:2 未解决外在

这里有一些关于设置的信息:

操作系统:W7 x64

构建命令:

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 光盘..

我已经在电脑上安装了 CYGWin。

这是我到目前为止所尝试的;

*我尝试在 32 位命令窗口中构建它(我正在使用 jenkins 构建 boost)

*我在 boost config/user.hpp 中写了#define BOOST_ALL_DYN_LINK

*我在 boost config/user.hpp 中写了#define BOOST_ALL_NO_LIB

有没有人遇到过这样的问题?我真的在任何地方都找不到任何东西?


编辑:

有关于我的问题的更新。我能够构建它以供发布。我唯一改变的是这里:

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 光盘..

可能是什么问题?我该如何解决?

提前感谢您的任何建议。

【问题讨论】:

  • 您可以使用 BOOST_NO_USER_CONFIG 抑制 user.hpp:groups.google.com/forum/#!topic/boost-list/OSkv0cKjpVM
  • @thomas 感谢您的评论。实际上我认为我需要 #define BOOST_ALL_DYN_LINK 定义,所以我将它添加到 user.hpp 作为我的配置。这样我定义了 BOOST_ALL_DYN_LINK 并且如果您阅读上面的评论,这似乎是必要的。默认情况下,我认为 user.hpp 没有被抑制,对吧?
  • 您是否尝试将#define BOOST_ALL_DYN_LINK 直接包含到 date_time/compiler_config.hpp 中?这可能是个坏主意,但那里似乎定义了 BOOST_DATE_TIME_DECL。
  • 感谢您的所有回答。我想我已经找到了解决方案并将其写下来,但我应该说我从你们的 cmets 中获得了灵感。 @thomas 抱歉,如果您已经表示答案,我无法正确理解。

标签: c++ boost build jenkins


【解决方案1】:

其实我已经找到了解决办法:

我使用 bjam 的方式是正确的,足以动态构建 boost。在那个阶段,我不应该定义任何东西。编译后我更改了 user.hpp 和 #define BOOST_ALL_DYN_LINK。 这样我自己的项目(正在使用 boost)将理解 boost 是动态的。这就是构建 boost 的方式。

这似乎是最好的方法,因为 boost 会按预期自动解码必要的库和 dll 并且运行良好。

【讨论】:

    【解决方案2】:

    我发现要实现成功的 boost 构建涉及很多手动步骤。如果您不想执行这些手动步骤并避免开销,请尝试BlueGo,前提是您想使用 MSVC 工具集。 BlueGo 允许配置 32/64 位、调试/发布模式等。

    【讨论】:

      【解决方案3】:

      我又遇到了这个问题。上一次我使用的是 boost 1.54。现在 - 提升 1.71。 我认为真正的原因是boost::thread依赖列表缺少boost::date_time。这两个版本都对我有用的是,将以下行添加到 libs/thread/build/Jamfile.v2 中的 requirements 规则的底部:

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

      我在 Github 上创建了一个issue,让我们看看。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-14
        • 1970-01-01
        • 1970-01-01
        • 2016-08-22
        • 2010-12-11
        • 2010-10-04
        相关资源
        最近更新 更多