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

build failure on gcc 11.1 #260

Closed
ChristophHaag opened this issue Jun 9, 2021 · 13 comments · Fixed by #276
Closed

build failure on gcc 11.1 #260

ChristophHaag opened this issue Jun 9, 2021 · 13 comments · Fixed by #276
Labels
synced to gitlab Synchronized to OpenXR internal GitLab

Comments

@ChristophHaag
Copy link
Contributor

Archlinux recently updated gcc to 11.1. Since then the openxr loader fails to compile.

[59/68] Linking CXX shared library src/loader/libopenxr_loader.so.1.0.17
FAILED: src/loader/libopenxr_loader.so.1.0.17 
: && /usr/lib/ccache/bin/c++ -fPIC -Wall -Werror=unused-parameter -Wpointer-arith -O2 -g -DNDEBUG  -Wl,--no-undefined  -Wl,--version-script=/home/haagch-collabora/OpenXR-SDK-Source/src/loader/openxr-loader.map -shared -Wl,-soname,libopenxr_loader.so.1 -o src/loader/libopenxr_loader.so.1.0.17 src/loader/CMakeFiles/openxr_loader.dir/api_layer_interface.cpp.o src/loader/CMakeFiles/openxr_loader.dir/loader_core.cpp.o src/loader/CMakeFiles/openxr_loader.dir/loader_instance.cpp.o src/loader/CMakeFiles/openxr_loader.dir/loader_logger.cpp.o src/loader/CMakeFiles/openxr_loader.dir/loader_logger_recorders.cpp.o src/loader/CMakeFiles/openxr_loader.dir/manifest_file.cpp.o src/loader/CMakeFiles/openxr_loader.dir/runtime_interface.cpp.o src/loader/CMakeFiles/openxr_loader.dir/__/xr_generated_dispatch_table.c.o src/loader/CMakeFiles/openxr_loader.dir/xr_generated_loader.cpp.o src/loader/CMakeFiles/openxr_loader.dir/__/common/object_info.cpp.o src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o  -ldl  -ljsoncpp  -lpthread && :
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetCurrentPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:102: undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetParentPath(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> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:109: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::parent_path() const'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetAbsolutePath(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> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:114: undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetAbsolutePath(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> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:114: undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetCanonicalPath(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> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:125: undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetCanonicalPath(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> >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:125: undefined reference to `std::experimental::filesystem::v1::canonical(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: /usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::_M_append(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:460: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::is_absolute() const':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:1200: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::has_root_directory() const'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::is_regular_file(std::experimental::filesystem::v1::__cxx11::path const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_ops.h:219: undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::is_directory(std::experimental::filesystem::v1::__cxx11::path const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_ops.h:177: undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::exists(std::experimental::filesystem::v1::__cxx11::path const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_ops.h:127: undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_path.h:230: undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `std::experimental::filesystem::v1::__cxx11::directory_iterator::directory_iterator(std::experimental::filesystem::v1::__cxx11::path const&)':
/usr/include/c++/11.1.0/experimental/bits/fs_dir.h:188: undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::directory_iterator(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::directory_options, std::error_code*)'
/usr/bin/ld: src/loader/CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsFindFilesInPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<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> > > >&)':
/home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:151: undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::operator*() const'
/usr/bin/ld: /home/haagch-collabora/OpenXR-SDK-Source/build/../src/common/filesystem_utils.cpp:151: undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::operator++()'

probably something wrong with the logic in https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/cmake/StdFilesystemFlags.cmake

workarounds:
1.

diff --git a/src/loader/CMakeLists.txt b/src/loader/CMakeLists.txt
index 8638bc6..bc60685 100644
--- a/src/loader/CMakeLists.txt
+++ b/src/loader/CMakeLists.txt
@@ -120,6 +120,7 @@ target_link_libraries(
     openxr_loader
     PRIVATE ${CMAKE_DL_LIBS}
     PUBLIC Threads::Threads
+    stdc++fs
 )
 target_compile_definitions(openxr_loader PRIVATE ${OPENXR_ALL_SUPPORTED_DEFINES})
 if(ANDROID)
  1. compile with clang

Possible cause: https://gcc.gnu.org/gcc-11/changes.html

The default mode for C++ is now -std=gnu++17 instead of -std=gnu++

@rpavlik
Copy link
Contributor

rpavlik commented Jun 9, 2021

Can you build verbose so that you can share the compile command? The CMake script sets the C++ standard to 14, so I'm curious whether it's ending up passing a command line arg at all.

@rpavlik-bot
Copy link
Collaborator

An issue (number 1571) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#1571 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

@rpavlik-bot rpavlik-bot added the synced to gitlab Synchronized to OpenXR internal GitLab label Jun 9, 2021
@ChristophHaag
Copy link
Contributor Author

Right, here is one full output with ninja --verbose

I see a bunch of -std=gnu++14 but if I see it correctly, no -std= at the step 64/68 that fails.

output.txt

@happysmash27
Copy link

Thank you so much for the workaround! I expected having to file an issue myself, and maybe even fix it myself, but your fix made everything work immediately!

@rygo6
Copy link

rygo6 commented Aug 11, 2021

I am getting a very similar error to this I believe. But it looks like the CMake file has changed and your patch doesn't some seem to fix it anymore. I am trying to build on the latest archlinux.

-- Enabling OpenGL support
-- Enabling Vulkan support
-- Presentation backend selected for hello_xr, loader_test, conformance: xlib
-- BUILD_WITH_XLIB_HEADERS: ON
-- BUILD_WITH_XCB_HEADERS: ON
-- BUILD_WITH_WAYLAND_HEADERS: ON
-- Found glslc: /home/ryan/vulkan/1.2.182.0/x86_64/bin/glslc
-- Found and will use pre-generated xr_generated_dispatch_table.h in source tree
-- Found and will use pre-generated xr_generated_dispatch_table.c in source tree
-- Found and will use pre-generated xr_generated_loader.hpp in source tree
-- Found and will use pre-generated xr_generated_loader.cpp in source tree
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ryan/Developer/OpenXR-SDK/build/linux_release
[  0%] Built target libopenxr_loader.so.1.0
[  0%] Built target xr_global_generated_files
[  0%] Built target generate_openxr_header
Consolidate compiler generated dependencies of target openxr_loader
[  8%] Linking CXX shared library libopenxr_loader.so
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetCurrentPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
filesystem_utils.cpp:(.text._Z26FileSysUtilsGetCurrentPathRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x32): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsIsAbsolutePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
filesystem_utils.cpp:(.text._Z26FileSysUtilsIsAbsolutePathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z26FileSysUtilsIsAbsolutePathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x94): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::has_root_directory() const'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsIsDirectory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
filesystem_utils.cpp:(.text._Z23FileSysUtilsIsDirectoryRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z23FileSysUtilsIsDirectoryRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x94): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsIsRegularFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
filesystem_utils.cpp:(.text._Z25FileSysUtilsIsRegularFileRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z25FileSysUtilsIsRegularFileRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x94): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsPathExists(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
filesystem_utils.cpp:(.text._Z22FileSysUtilsPathExistsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z22FileSysUtilsPathExistsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x94): undefined reference to `std::experimental::filesystem::v1::status(std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetParentPath(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> >&)':
filesystem_utils.cpp:(.text._Z25FileSysUtilsGetParentPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xaf): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z25FileSysUtilsGetParentPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xc5): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::parent_path() const'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetCanonicalPath(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> >&)':
filesystem_utils.cpp:(.text._Z28FileSysUtilsGetCanonicalPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0x36): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z28FileSysUtilsGetCanonicalPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xc1): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z28FileSysUtilsGetCanonicalPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xdc): undefined reference to `std::experimental::filesystem::v1::canonical(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsGetAbsolutePath(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> >&)':
filesystem_utils.cpp:(.text._Z27FileSysUtilsGetAbsolutePathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0x36): undefined reference to `std::experimental::filesystem::v1::current_path[abi:cxx11]()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z27FileSysUtilsGetAbsolutePathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xc1): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z27FileSysUtilsGetAbsolutePathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERS4_+0xdc): undefined reference to `std::experimental::filesystem::v1::absolute(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::__cxx11::path const&)'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsCombinePaths(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&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
filesystem_utils.cpp:(.text._Z24FileSysUtilsCombinePathsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RS4_+0xb8): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z24FileSysUtilsCombinePathsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RS4_+0x14b): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z24FileSysUtilsCombinePathsRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RS4_+0x2c8): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: CMakeFiles/openxr_loader.dir/__/common/filesystem_utils.cpp.o: in function `FileSysUtilsFindFilesInPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<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> > > >&)':
filesystem_utils.cpp:(.text._Z27FileSysUtilsFindFilesInPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS4_SaIS4_EE+0xc0): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z27FileSysUtilsFindFilesInPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS4_SaIS4_EE+0xd1): undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::directory_iterator(std::experimental::filesystem::v1::__cxx11::path const&, std::experimental::filesystem::v1::directory_options, std::error_code*)'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z27FileSysUtilsFindFilesInPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS4_SaIS4_EE+0x2db): undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::operator*() const'
/usr/bin/ld: filesystem_utils.cpp:(.text._Z27FileSysUtilsFindFilesInPathRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS4_SaIS4_EE+0x49e): undefined reference to `std::experimental::filesystem::v1::__cxx11::directory_iterator::operator++()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/loader/CMakeFiles/openxr_loader.dir/build.make:258: src/loader/libopenxr_loader.so.1.0.18] Error 1
make[1]: *** [CMakeFiles/Makefile2:255: src/loader/CMakeFiles/openxr_loader.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

@rpavlik
Copy link
Contributor

rpavlik commented Aug 11, 2021

Yeah, the patch is unfortunately not a solution we can upstream.

Are folks who are trying this starting with a clean build directory? If https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/cmake/StdFilesystemFlags.cmake ran and determined one way to get stdc++fs, then the compiler is upgraded, that would explain what we're seeing. Otherwise https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/cmake/StdFilesystemFlags.cmake is somehow failing to correctly detect how to link that.

@rygo6
Copy link

rygo6 commented Aug 12, 2021

I am doing the build from a fresh clone, also a fresh install of manjaro.

I've trying to build the non 'Source' version of this. But they look to have the same exact cmake setup, so it should be the same issue.
https://github.com/KhronosGroup/OpenXR-SDK/blob/master/src/cmake/StdFilesystemFlags.cmake

I did install this package:
https://archlinux.org/packages/extra/x86_64/libstdc++5/

Is there some other dependency that this could rest on which maybe I am missing?

@rygo6
Copy link

rygo6 commented Aug 12, 2021

building with clang works like a charm, but would be nice to figure out issue with gcc

@rpavlik
Copy link
Contributor

rpavlik commented Aug 12, 2021

I'm reasonably certain you shouldn't need libstdc++5, I think that's for really old binaries. The CMake is just not properly detecting on Arch or Manjaro whether it needs to add stdc++fs to the link line. @ChristophHaag is probably in the best position to help here since I work with him and he's an experienced arch user. Otherwise I'd have to grab a docker image or vm or something and try myself, and I'm pretty overbooked at the moment

@ChristophHaag
Copy link
Contributor Author

The better workaround is to use cmake with -DBUILD_WITH_STD_FILESYSTEM=OFF instead of editing the files.

@rpavlik
Copy link
Contributor

rpavlik commented Aug 13, 2021

Yes, that's definitely better. I did improve the documentation and structure of the associated file in this branch, including some TODOs that might be relevant: https://github.com/rpavlik/OpenXR-SDK-Source/tree/debug-cmake-gcc11

@ChristophHaag
Copy link
Contributor Author

Just posting so it's not forgotten. It seems the cmake files are checking what flags are needed when compiling in c++17 mode, but c++17 mode isn't actually set when compiling the loader.

So on gcc 11 it compiles with this

diff --git a/src/loader/CMakeLists.txt b/src/loader/CMakeLists.txt
index 8638bc6..7ee9eb9 100644
--- a/src/loader/CMakeLists.txt
+++ b/src/loader/CMakeLists.txt
@@ -240,6 +240,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
                 -ffunction-sections
                 -fdata-sections
     )
+    set_property(TARGET openxr_loader PROPERTY CXX_STANDARD 17)
+
     # Make build depend on the version script/export map
     target_sources(openxr_loader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/openxr-loader.map)
     # Add the linker flag.

But also looking back at my comment #260 (comment) I tried just removing the project wide c++14 setting and it worked too.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0c34992..af9e656 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,7 +22,6 @@ if(POLICY CMP0075)
 endif()

 # Entire project uses C++14
-set(CMAKE_CXX_STANDARD 14)
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

Someone more familiar with cmake and the c++ standard settings will need to decide what the right fix is.

@rpavlik
Copy link
Contributor

rpavlik commented Oct 26, 2021

So what @ChristophHaag did is basically what my fix in #276 does: if it detects GCC 11+, it sets the configuration variable to indicate that C++17 is required for use of std::filesystem. Then everything works right. Telling GCC 11 to use C++14 in the project isn't persisting through to the try-compiles, so we're getting "yep we have c++17 std::filesystem" in the test builds that then fails at real compile time.

acgetchell added a commit to acgetchell/CDT-plusplus that referenced this issue Jan 4, 2023
Seems like for gcc the use of <filesystem> only works in c++17 mode.

KhronosGroup/OpenXR-SDK-Source#260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
synced to gitlab Synchronized to OpenXR internal GitLab
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants