我在 Windows 上从源代码构建了 boost。我可以在 Windows 上用它编译。</p>
当我想在 linux 中用它编译时:
Unable to find the requested Boost libraries.
Boost version: 1.65.1
Boost include path: pathtoproject/deps/boost
Could not find the following Boost libraries:
boost_system
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.
所以我设置了 findboost 调试标志来理解为什么使用
set(Boost_DEBUG 1)
在 CMake 中。我得到:
Boost_FOUND = 1
还有
Searching for SYSTEM_LIBRARY_RELEASE: boost_system-gcc54-mt-1_65_1;boost_system-gcc54-mt;boost_system-mt-1_65_1;boost_system-mt;boost_system
这意味着 cmake 正在寻找名为“gcc54”的库。
但我的库名为“vc141”(msvc)。
那么它可以工作还是我需要 2 个 boost 版本才能在两个系统上工作。
最佳答案
您通常不能在编译器之间混合搭配,除非明确支持。在这种情况下,它非常不受支持。
关于c++ - 可以在linux程序中使用带有msvc的在windows上构建的lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46625017/