C++ 对boost::filesystem::path\u traits::dispatch的未定义引用

C++ 对boost::filesystem::path\u traits::dispatch的未定义引用,c++,boost,C++,Boost,我使用boost文件系统库编写了一个简单的程序。我链接到了libboost\u文件系统,但是我得到了未定义的引用链接错误。 这是我的CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(client) add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") add_executab

我使用boost文件系统库编写了一个简单的程序。我链接到了
libboost\u文件系统
,但是我得到了未定义的引用链接错误。
这是我的CMakeLists.txt

 cmake_minimum_required(VERSION 2.8)

 project(client)
 add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
 add_executable(client main.cpp UploadWorker.cpp FileSystemWatcher.cpp)
 target_link_libraries(client boost_filesystem boost_system pthread)
我在其他主题中尝试了所有的解决方案,但没有一个是有用的

这是我的错误:

-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 4.9.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/saeed/projects/threads/Debug
Scanning dependencies of target client
Scanning dependencies of target server
[ 50%] Building CXX object server/CMakeFiles/server.dir/main.cpp.o
[ 50%] Building CXX object client/CMakeFiles/client.dir/main.cpp.o
[ 50%] Building CXX object client/CMakeFiles/client.dir/UploadWorker.cpp.o
[ 66%] Building CXX object client/CMakeFiles/client.dir/FileSystemWatcher.cpp.o
[ 83%] Linking CXX executable server
[ 83%] Built target server
[100%] Linking CXX executable client
CMakeFiles/client.dir/FileSystemWatcher.cpp.o: In function `boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*)':
/usr/include/boost/filesystem/path.hpp:140: undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)'
collect2: error: ld returned 1 exit status
client/CMakeFiles/client.dir/build.make:146: recipe for target 'client/client' failed
make[2]: *** [client/client] Error 1
CMakeFiles/Makefile2:85: recipe for target 'client/CMakeFiles/client.dir/all' failed
make[1]: *** [client/CMakeFiles/client.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
——C编译器标识是GNU 5.4.1
--CXX编译器标识为GNU 4.9.4
--检查C编译器是否工作:/usr/bin/cc
--检查C编译器是否工作:/usr/bin/cc--works
--检测C编译器ABI信息
--检测C编译器ABI信息-完成
--检测C编译特性
--检测C编译特性-完成
--检查CXX编译器是否工作:/usr/bin/c++
--检查CXX编译器是否正常工作:/usr/bin/c++--正常工作
--检测CXX编译器ABI信息
--检测CXX编译器ABI信息-完成
--检测CXX编译特性
--检测CXX编译功能-完成
--配置完成
--生成完成
--生成文件已写入:/home/saeed/projects/threads/Debug
扫描目标客户端的依赖项
扫描目标服务器的依赖项
[50%]构建CXX对象服务器/cmakfiles/server.dir/main.cpp.o
[50%]构建CXX对象客户端/cmakfiles/client.dir/main.cpp.o
[50%]构建CXX对象客户端/cmakfiles/client.dir/UploadWorker.cpp.o
[66%]构建CXX对象客户端/cmakfiles/client.dir/FileSystemWatcher.cpp.o
[83%]链接CXX可执行服务器
[83%]内置目标服务器
[100%]链接CXX可执行客户端
cmakfiles/client.dir/FileSystemWatcher.cpp.o:在函数“boost::filesystem::path::path(boost::filesystem::directory_entry const&,boost::enable_if::type*)”中:
/usr/include/boost/filesystem/path.hpp:140:boost::filesystem::path\u traits::dispatch(boost::filesystem::directory\u entry const&,std::string&)的未定义引用
collect2:错误:ld返回了1个退出状态
client/CMakeFiles/client.dir/build.make:146:目标“client/client”的配方失败
生成[2]:***[client/client]错误1
CMakeFiles/Makefile2:85:目标“client/CMakeFiles/client.dir/all”的配方失败
生成[1]:***[client/CMakeFiles/client.dir/all]错误2
Makefile:83:目标“全部”的配方失败
make:**[全部]错误2

我的机器是Ubuntu 16.04、g++v4.9.4和boost v1.58。

还有你的编译和链接/加载命令?@Walter:Just
cmake。。;make-j是的,但是生成的编译命令是什么?@Walter:aha:)更新了我的问题。嗯,这仍然没有显示编译和链接命令本身。我没有Boost1.58,但是更新到最新版本可能是个好主意。。。