Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc requires linking stdc++fs #10352

gibmat opened this issue Dec 10, 2019 · 1 comment · Fixed by #10522

gcc requires linking stdc++fs #10352

gibmat opened this issue Dec 10, 2019 · 1 comment · Fixed by #10522


Copy link

@gibmat gibmat commented Dec 10, 2019

OS: Debian buster x86_64 (10.2)
Version: develop
Commit/Build: e72d2ab
gcc: (Debian 8.3.0-6) 8.3.0
cmake: 3.13.4

As mentioned in pull request #10261, older versions of gcc require linking stdc++fs. I do a personal build of OpenRCT2 about once a month, so I've just hit this after pulling current develop. As-is, anyone using a version of gcc older than 9.0 can't compile the project. This is potentially a lot of people, as for example Debian buster ships with gcc 8.3.

Locally I've just added a target_link_libraries line to the CMakeLists.txt and I'm able to build again, but a better solution is needed.

Steps to reproduce:

  1. Checkout current develop
  2. Build with gcc < 9


[ 73%] Linking CXX executable openrct2-cli
/usr/bin/ld: libopenrct2.a(Path.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)':
Path.cpp:(.text._ZNSt10filesystem7__cxx114pathC2EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS1_6formatE[_ZNSt10filesystem7__cxx114pathC5EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS1_6formatE]+0x4f): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: libopenrct2.a(Path.cpp.o): in function `std::filesystem::__cxx11::path::extension() const':
Path.cpp:(.text._ZNKSt10filesystem7__cxx114path9extensionEv[_ZNKSt10filesystem7__cxx114path9extensionEv]+0x19): undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const'
/usr/bin/ld: libopenrct2.a(Path.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>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::filesystem::__cxx11::path::format)':
Path.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x64): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/openrct2-cli.dir/build.make:88: openrct2-cli] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/openrct2-cli.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Quick fix

gibmat@aule:~/OpenRCT2$ git diff
diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt
index 97674911c..a5b24aaea 100644
--- a/src/openrct2/CMakeLists.txt
+++ b/src/openrct2/CMakeLists.txt
@@ -217,3 +217,5 @@ else ()
     # Dummy target to ease invocation
 endif ()
+target_link_libraries(libopenrct2 stdc++fs)

This comment has been minimized.

Copy link

@tomlankhorst tomlankhorst commented Jan 5, 2020

Yes, this is the current state of affairs with GCC.

Wrapping the target_link_libraries in if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") is a little better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.