我有静态或动态 boost 库吗?

2023-07-19C/C++开发问题
2

本文介绍了我有静态或动态 boost 库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我已经运行了 bjam.exe --build-dir="C:uild-boost" --build-type=minimal msvc stage

现在我有带有这些头文件的库 .lib,例如

and now I have libraries .lib with these headers, for example

libboost_serialization-vc100-mt
libboost_serialization-vc100-mt-1_45
libboost_serialization-vc100-mt-gd
libboost_serialization-vc100-mt-gd-1_45

我相信这些应该是用于调试和发布版本的静态库.当我使用 Multi-threaded Debug (/MTd) 运行编译器时,它给出错误 LNK1104: cannot open file 'libboost_serialization-vc100-mt-sgd-1_45.lib'它正在寻找一个 -sgd

I believe these should be static libraries for debug and release version. When I run the compiler with Multi-threaded Debug (/MTd) it gives an error LNK1104: cannot open file 'libboost_serialization-vc100-mt-sgd-1_45.lib' It is looking for one with -sgd

我哪里出错了?

推荐答案

有点令人困惑的是,使用 MSVC 构建 boost 有两个静态"选项.

Something that is kind of confusing is there are two 'static' options for building boost with MSVC.

B2.exe 采用选项 link=static,它告诉 boost 您想要静态链接 IT.如果您使用/MT 或/MTd 编译您的 VC 项目,您还需要使用 runtime-link=static 选项来告诉 boost 您将静态链接到 VC 运行时库.

B2.exe takes the option link=static which tells boost that you want to link IT statically. If you are compiling your VC project with /MT or /MTd you will also need to use the runtime-link=static option to tell boost that you will be linking to the VC runtime libraries statically.

第二个 runtime-link=static 将 -s 放在 .lib 名称中.

It is the second runtime-link=static which puts the -s in the .lib name.

我用于构建 boost 的命令行是

My command line for building boost was

b2.exe --toolset=msvc variant=release link=static threading=multi runtime-link=static stage

这篇关于我有静态或动态 boost 库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6