Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';即使使用-lstdc++;财政司司长_C++_Cmake_Linker_Std - Fatal编程技术网

C++ Can';即使使用-lstdc++;财政司司长

C++ Can';即使使用-lstdc++;财政司司长,c++,cmake,linker,std,C++,Cmake,Linker,Std,我正在尝试编译一个使用std::filesystem的应用程序。我使用CMake构建系统,使用g++-8作为编译器 My CMakeLists.txt包括target\u link\u库(公共stdc++fs)和set(CMAKE\u CXX\u标准17) make VERBOSE=1显示链接器命令中使用了-lstdc++fs 尽管如此,我在使用std::filesystem组件的任何地方都会得到未定义的引用 它在Docker中编译得很好,因此这显然是一个环境问题 找到这个有什么建议吗 编辑:

我正在尝试编译一个使用std::filesystem的应用程序。我使用CMake构建系统,使用g++-8作为编译器

My CMakeLists.txt包括
target\u link\u库(公共stdc++fs)
set(CMAKE\u CXX\u标准17)

make VERBOSE=1
显示链接器命令中使用了
-lstdc++fs

尽管如此,我在使用std::filesystem组件的任何地方都会得到未定义的引用

它在Docker中编译得很好,因此这显然是一个环境问题

找到这个有什么建议吗

编辑: 由于公司规定,我不能发布准确的错误消息,而且它也很长。不过,我会发布一个截断的匿名版本:

CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `ProjectName::ClassName::update(ProjectName::Body&)':
/home/username/prog/bots/src/ui/dir_a/file_a.cpp:30: undefined reference to `std::filesystem::current_path[abi:cxx11]()'
/home/username/prog/bots/src/ui/dir_a/file_a.cpp:35: undefined reference to `std::filesystem::create_directories(std::filesystem::__cxx11::path const&)'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::__cxx11::path::operator+=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/8/bits/fs_path.h:817: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::__cxx11::path::operator+=(char const*)':
/usr/include/c++/8/bits/fs_path.h:825: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
CMakeFiles/ProjectName.dir/src/ui/dir_a/file_a.cpp.o: In function `std::filesystem::exists(std::filesystem::__cxx11::path const&)':
/usr/include/c++/8/bits/fs_ops.h:121: undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
CMakeFiles/ProjectName.dir/src/ui/dir_b/file_b.cpp.o: In function `ProjectName::ClassName::update[abi:cxx11]()':
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:30: undefined reference to `std::filesystem::current_path[abi:cxx11]()'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:34: undefined reference to `std::filesystem::create_directories(std::filesystem::__cxx11::path const&)'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:36: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:40: undefined reference to `std::filesystem::__cxx11::path::replace_extension(std::filesystem::__cxx11::path const&)'
/home/username/prog/bots/src/ui/dir_b/file_b.cpp:36: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
CMakeFiles/ProjectName.dir/src/ui/dir_b/file_b.cpp.o: In function `std::filesystem::__cxx11::path::path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::filesystem::__cxx11::path::format)':
/usr/include/c++/8/bits/fs_path.h:177: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'

升级到g++9解决了问题,但是如果有人知道如何解决问题并且仍然使用g++8,我会接受这个答案。

升级到g++9解决了问题,但是如果有人知道如何解决问题并且仍然使用g++8,我会接受这个答案。

您使用的是什么平台?请发布准确的错误消息好吗?还有特定版本的软件。您使用的是编译器附带的libstdc++还是系统附带的libstdc++(如果不是相同的话)?请参见以下内容:@IlyaPopov谢谢您的帮助。我已经在OP中添加了更多细节。我不确定CMake链接的是哪个版本的stdc++,你知道我该如何检查吗?我将试一试g++-9。您使用的是什么平台?您可以发布准确的错误消息吗?还有特定版本的软件。您使用的是编译器附带的libstdc++还是系统附带的libstdc++(如果不是相同的话)?请参见以下内容:@IlyaPopov谢谢您的帮助。我已经在OP中添加了更多细节。我不确定CMake链接的是哪个版本的stdc++,你知道我该如何检查吗?我会试试g++-9。
Ubuntu 18.04
g++-8 (installed with `apt`)
CMake 3.14.2