我尝试使用std :: experimental :: filesystem的c ++ 1z功能
在使用g ++添加-lstdc ++ fs标志后,我可以将std :: experimental :: filesystem :: v1 :: __ cxx11 :: path :: _ M_split_cmpts()链接到我的程序。
即我不再收到此错误
sdc.cpp :(。text + 0x7e5):未定义引用`std :: experimental :: filesystem :: v1 :: __ cxx11 :: path :: _ M_split_cmpts()'
但是,即使在链接后,我也会收到以下错误消息。
g ++ -std = c ++ 1z timer.cpp -lstdc ++ fs -O2 -I include -L lib -lOpenTimer -lpthread -o timer.out lib / libOpenTimer.a(spef.cpp.o):在函数
spef::Spef::read(std::experimental::filesystem::v1::__cxx11::path const&)': spef.cpp:(.text._ZN4spef4Spef4readERKNSt12experimental10filesystem2v17__cxx114pathE[_ZN4spef4Spef4readERKNSt12experimental10filesystem2v17__cxx114pathE]+0x2e): undefined reference to
std :: experimental :: filesystem :: v1 :: status(std :: experimental :: filesystem :: v1 :: __ cxx11 :: path中const&)' lib / libOpenTimer.a(sdc.cpp.o):在函数ot::sdc::home[abi:cxx11]()': sdc.cpp:(.text+0x414): undefined reference to
std :: experimental :: filesystem :: v1 :: status(std :: experimental :: filesystem :: v1 :: __ cxx11 :: path中const&)' sdc.cpp :(。text + 0x7ab):对std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)' lib/libOpenTimer.a(sdc.cpp.o): In function
ot :: sdc :: SDC :: read(std :: experimental :: filesystem :: v1 :: __ cxx11 :: path const&)'的未定义引用: sdc.cpp :(。text + 0x2fa1):对std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)' sdc.cpp:(.text+0x3084): undefined reference to
std :: experimental :: filesystem :: v1 :: status(std :: experimental :: filesystem :: v1 :: __ cxx11 :: path const&的未定义引用)' sdc.cpp :(。text + 0x30db):对std::experimental::filesystem::v1::current_path[abi:cxx11]()' sdc.cpp:(.text+0x30f7): undefined reference to
std :: experimental :: filesystem :: v1 :: absolute(std :: experimental :: filesystem :: v1 :: __ cxx11 :: path const&的未定义引用,std :: experimental :: filesystem :: v1 :: ____ cxx11 :: path const&)' sdc.cpp :(。text + 0x3788):对std::experimental::filesystem::v1::remove(std::experimental::filesystem::v1::__cxx11::path const&)' lib/libOpenTimer.a(os.cpp.o): In function
ot :: user_homeabi:cxx11'的未定义引用: os.cpp :(。text + 0x30d):对`std :: experimental :: filesystem :: v1 :: current_pathabi:cxx11'的未定义引用 collect2:错误:ld返回1退出状态
任何帮助解决此问题的方法将不胜感激。
答案 0 :(得分:0)
是我发布了问题。看来我自己能够解决它。
我在末尾添加了-lstdc ++ fs而不是在中间,它开始工作。
这是更新的命令
g ++ -std = c ++ 1z timerapp.cpp -O2-我包括-L lib -lOpenTimer -lpthread -o timer.out -lstdc ++ fs
与上一个命令相比
g ++ -std = c ++ 1z timerapp.cpp -lstdc ++ fs -O2 -I include -L lib -lOpenTimer -lpthread -o timer.out
不知道为什么最终希望添加一些链接标志。