boost的
我正在尝试构建以下代码:
"Source.cpp"的内容
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
int main(int argc, char* argv[])
{
path myPath("foo");
if (exists(myPath)) ...
}
我用来编译它的命令是:
g++ -Wall -I D:boost_1_72_0 Source.cpp -o test -L D:boost_1_72_0stagelib -lboost_filesystem-vc142-mt-gd-x32-1_72
但我得到默认未解决的符号错误:
C:UsersUserAppDataLocalTempccskBqAh.o:Source.cpp:(.text$_ZN5boost10filesystem11path_traits7convertEPKcS3_RNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE[__ZN5boost10filesystem11path_traits7convertEPKcS3_RNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE]+0x7): undefined reference to `boost::filesystem::path::codecvt()'
... etc
不过,当我用Visual Studio编译它时没有问题。
p.s.允许在"-L"one_answers"-I"后面留空格。我试着把不同的libs连接起来。对于共享,我还使用#define BOOST_ALL_DYN_LINK以防万一。
共享:
boost_filesystem-vc142-mt-gd-x32-1_72
boost_filesystem-vc142-mt-gd-x64-1_72
boost_filesystem-vc142-mt-x32-1_72
boost_filesystem-vc142-mt-x64-1_72
静态:
libboost_filesystem-vc142-mt-gd-x32-1_72
libboost_filesystem-vc142-mt-gd-x64-1_72
libboost_filesystem-vc142-mt-sgd-x32-1_72
libboost_filesystem-vc142-mt-sgd-x64-1_72
libboost_filesystem-vc142-mt-s-x32-1_72
libboost_filesystem-vc142-mt-s-x64-1_72
libboost_filesystem-vc142-mt-x64-1_72
Visual Studio
二进制文件与MinGW
不兼容。您将需要使用工具链生成的boost二进制文件。虽然许多c
库可以使用其他c
编译器生成的二进制文件,但c++
库通常不兼容。
以下问题解释了c++
中ABI不相容性的困难:保证C++库的二进制兼容性的简单方法,C链接?