rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.64k stars 306 forks source link

[Build failed] ld cannot find stdc++fs: ld: undefined reference to std::filesystem #578

Open arthurkiller opened 1 month ago

arthurkiller commented 1 month ago

build command:

cmake -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -Wno-dev -DCMAKE_INSTALL_LIBDIR=/usr/lib/gcc/x86_64-linux-gnu/ ..

failed output log

[ 94%] Linking CXX executable wrapper
/usr/bin/ld: CMakeFiles/wrapper_a.dir/source/report/wrapper/RpcClients.cc.o: in function `wr::SupervisorClient::resolve(domain::Execution const&)':
[RpcClients.cc](http://rpcclients.cc/):(.text+0x6ad): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [RpcClients.cc](http://rpcclients.cc/):(.text+0x6cc): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [RpcClients.cc](http://rpcclients.cc/):(.text+0x7d5): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [RpcClients.cc](http://rpcclients.cc/):(.text+0x7f5): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [RpcClients.cc](http://rpcclients.cc/):(.text+0x92b): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/wrapper_a.dir/source/report/wrapper/RpcClients.cc.o:[RpcClients.cc](http://rpcclients.cc/):(.text+0x94a): more undefined references to `std::filesystem::__cxx11::path::_M_split_cmpts()' follow
/usr/bin/ld: CMakeFiles/wrapper_a.dir/source/report/wrapper/Application.cc.o: in function `wr::Application::command(int, char const**, char const**) const':
[Application.cc](http://application.cc/):(.text+0x9ccf): undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
/usr/bin/ld: [Application.cc](http://application.cc/):(.text+0xa140): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Application.cc](http://application.cc/):(.text+0xa15f): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Application.cc](http://application.cc/):(.text+0xa255): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Application.cc](http://application.cc/):(.text+0xa275): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/wrapper_a.dir/source/report/wrapper/Application.cc.o: in function `rust::Result<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, domain::Execution>, std::runtime_error> rust::Result<domain::Execution, std::runtime_error>::map<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, domain::Execution> >(std::function<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, domain::Execution> (domain::Execution const&)> const&) const':
[Application.cc](http://application.cc/):(.text._ZNK4rust6ResultIN6domain9ExecutionESt13runtime_errorE3mapISt5tupleIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES2_EEEENS0_IT_S3_EERKSt8functionIFSE_RKS2_EE[_ZNK4rust6ResultIN6domain9ExecutionESt13runtime_errorE3mapISt5tupleIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES2_EEEENS0_IT_S3_EERKSt8functionIFSE_RKS2_EE]+0xc4): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/wrapper_a.dir/source/report/wrapper/Application.cc.o:[Application.cc](http://application.cc/):(.text._ZNK4rust6ResultIN6domain9ExecutionESt13runtime_errorE3mapISt5tupleIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES2_EEEENS0_IT_S3_EERKSt8functionIFSE_RKS2_EE[_ZNK4rust6ResultIN6domain9ExecutionESt13runtime_errorE3mapISt5tupleIJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES2_EEEENS0_IT_S3_EERKSt8functionIFSE_RKS2_EE]+0xdd): more undefined references to `std::filesystem::__cxx11::path::_M_split_cmpts()' follow
/usr/bin/ld: CMakeFiles/domain_a.dir/source/Domain.cc.o: in function `domain::operator==(domain::Execution const&, domain::Execution const&)':
[Domain.cc](http://domain.cc/):(.text+0x15): undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
/usr/bin/ld: [Domain.cc](http://domain.cc/):(.text+0x9b): undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
/usr/bin/ld: CMakeFiles/domain_a.dir/source/Convert.cc.o: in function `domain::from(rpc::Execution const&)':
[Convert.cc](http://convert.cc/):(.text+0x142): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Convert.cc](http://convert.cc/):(.text+0x242): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: ../libsys/CMakeFiles/sys_a.dir/source/Process.cc.o: in function `sys::Process::Builder::Builder(std::filesystem::__cxx11::path, bool)':
[Process.cc](http://process.cc/):(.text+0x436): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Process.cc](http://process.cc/):(.text+0x44d): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: ../libsys/CMakeFiles/sys_a.dir/source/Process.cc.o: in function `(anonymous namespace)::spawn_process_with_retry(int (*)(int*, char const*, posix_spawn_file_actions_t const*, posix_spawnattr_t const*, char* const*, char* const*), std::filesystem::__cxx11::path const&, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, bool)':
[Process.cc](http://process.cc/):(.text+0x1e77): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: ../libsys/CMakeFiles/sys_a.dir/source/Process.cc.o:[Process.cc](http://process.cc/):(.text+0x2634): more undefined references to `std::filesystem::__cxx11::path::_M_split_cmpts()' follow
/usr/bin/ld: ../libsys/CMakeFiles/sys_a.dir/source/Path.cc.o: in function `sys::path::get_cwd[abi:cxx11]()':
[Path.cc](http://path.cc/):(.text+0x4d4): undefined reference to `std::filesystem::current_path[abi:cxx11](std::error_code&)'
/usr/bin/ld: [Path.cc](http://path.cc/):(.text+0x66f): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Path.cc](http://path.cc/):(.text+0x688): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Path.cc](http://path.cc/):(.text+0x727): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Path.cc](http://path.cc/):(.text+0x746): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: [Path.cc](http://path.cc/):(.text+0x7c3): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: ../libsys/CMakeFiles/sys_a.dir/source/Path.cc.o:[Path.cc](http://path.cc/):(.text+0x7e2): more undefined references to `std::filesystem::__cxx11::path::_M_split_cmpts()' follow
collect2: error: ld returned 1 exit status
make[5]: *** [intercept/CMakeFiles/wrapper.dir/build.make:196: intercept/wrapper] Error 1
make[4]: *** [CMakeFiles/Makefile2:481: intercept/CMakeFiles/wrapper.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
[ 94%] Built target citnames_a
make[3]: *** [Makefile:136: all] Error 2
make[2]: *** [CMakeFiles/BearSource.dir/build.make:87: subprojects/Stamp/BearSource/BearSource-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:174: CMakeFiles/BearSource.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

question: how can I fix this issue?

rizsotto commented 1 month ago

Well, this is not enough info to help you out. Have you checked the INSTALL.md what tools you require?

My guess is that you don't have a recent compiler.

arthurkiller commented 4 weeks ago

Hi, thx for your replyI’v checked all docs above and tried add -l with c++fslib, but still not work. I am not a CMake expert, not sure where goes wrongHave an awesome day✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️Arthur leeSent from my iPhone在 2024年6月8日,上午10:10,László Nagy @.***> 写道: Well, this is not enough info to help you out. Have you checked the INSTALL.md what tools you require? My guess is that you don't have a recent compiler.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

arthurkiller commented 4 weeks ago

But I can build other libs based on my compiler eg protobuffer sourceHave an awesome day✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️Arthur leeSent from my iPhone在 2024年6月8日,上午10:10,László Nagy @.***> 写道: Well, this is not enough info to help you out. Have you checked the INSTALL.md what tools you require? My guess is that you don't have a recent compiler.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

liyakai commented 1 week ago

https://support.scitools.com/support/solutions/articles/70000647772-installing-rizsotto-bear-on-centos-rhel-8 @arthurkiller May it could help you. I solved the problem.