栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

undefined reference to `std::filesystem

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

undefined reference to `std::filesystem

在gcc8.3中使用filesystem,没想到编译加了-std=c++17还是报错。

/home/yuanll/disk2/rk1109/SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/aibox.dir/src/app/main.cpp.o: in function `std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&)':
main.cpp:(.text._ZNSt10filesystem7__cxx114pathdVERKS1_[_ZNSt10filesystem7__cxx114pathdVERKS1_]+0x3c): undefined reference to `std::filesystem::__cxx11::path::has_filename() const'
/home/yuanll/disk2/rk1109/SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.cpp:(.text._ZNSt10filesystem7__cxx114pathdVERKS1_[_ZNSt10filesystem7__cxx114pathdVERKS1_]+0xa0): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/home/yuanll/disk2/rk1109/SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/aibox.dir/src/app/main.cpp.o: in function `std::filesystem::__cxx11::path::clear()':
main.cpp:(.text._ZNSt10filesystem7__cxx114path5clearEv[_ZNSt10filesystem7__cxx114path5clearEv]+0x20): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/home/yuanll/disk2/rk1109/SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/aibox.dir/src/app/main.cpp.o: in function `std::filesystem::__cxx11::path::is_absolute() const':
main.cpp:(.text._ZNKSt10filesystem7__cxx114path11is_absoluteEv[_ZNKSt10filesystem7__cxx114path11is_absoluteEv]+0x14): undefined reference to `std::filesystem::__cxx11::path::has_root_directory() const'
/home/yuanll/disk2/rk1109/SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/aibox.dir/src/app/main.cpp.o: in function `std::filesystem::__cxx11::path::path, std::allocator >, std::filesystem::__cxx11::path>(std::__cxx11::basic_string, std::allocator > const&, std::filesystem::__cxx11::path::format)':
main.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x60): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: 错误: ld 返回 1

解决办法:-lstdc++fs

具体原理请参考:filesystem太难用了!

c++真是博大精深!!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1034560.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号