我正在尝试构建以下代码:
“ 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_0\stage\lib -lboost_filesystem-vc142-mt-gd-x32-1_72
但是我得到默认的未解决符号错误:
C:\Users\User\AppData\Local\Temp\ccskBqAh.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”和“ -I”之后的空格。而且我尝试链接不同的库。对于共享,我还使用了#define BOOST_ALL_DYN_LINK以防万一。
Shared:
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
不兼容。您将需要使用工具链生成的增强二进制文件。