【问题标题】:Is it possible to compile boost::recursive_mutex statically in C++ Builder是否可以在 C++ Builder 中静态编译 boost::recursive_mutex
【发布时间】:2023-03-23 07:46:01
【问题描述】:

boost::recursive_mutexboost::lock_guard 似乎在 C++ Builder 2010 中使用 boost_thread-bcb-mt-1_39.dll。我看到还有静态版本 - boost_thread-bcb- mt-1_39.lib.

我的代码是这样的:

boost::recursive_mutex mylock;
//...
boost::lock_guard<boost::recursive_mutex> lock(mylock);

但是,如果我将编译选项设置为 Release 并将动态 RTL 选项设置为 False,我得到的只是 将 dll boost 库与静态运行时混合是一个非常糟糕的主意...。将动态 RTL 返回到 True 会编译,但它需要额外的 DLL - cc32100mt.dllboost_thread-bcb-mt-1_39.dll。。 p>

有没有办法在单个 exe 中静态编译它?毕竟提供了LIB文件,应该是可以的。这个版本的 C++ Builder 或 Boost 有问题吗?

【问题讨论】:

    标签: c++ boost c++builder boost-thread c++builder-2010


    【解决方案1】:

    我需要在头文件中定义:

    #define BOOST_THREAD_USE_LIB
    

    就在之前:

    #include <boost/thread/recursive_mutex.hpp>
    #include <boost/thread/locks.hpp>
    

    然后它编译没有任何问题。

    【讨论】:

      猜你喜欢
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多