gemma.cpp
gemma.cpp copied to clipboard
Bugfix: fix compiler linker can't find std::filesystem
In some compilers that support only some C++17 features like gcc6.3.0, it may encounter a situation where std filesystem lib can't be found, like:
/usr/bin/ld: CMakeFiles/gemma.dir/gemma.cc.o: in function `std::filesystem::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::filesystem::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::filesystem::__cxx11::path::format)':
[gemma.cc](http://gemma.cc/):(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x74): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
So we need to explicitly link the std::filesystem library in cmake.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Thanks! Does this also work for clang, or do we require some logic to detect which one to link against? Something like https://github.com/ned14/llfio/issues/52 ?
Thank you @friendlyanon , I agree this sounds like a good approach, let's go with that :) Please feel free to reopen if you'd like to discuss further.