-
Notifications
You must be signed in to change notification settings - Fork 354
Description
Bug category
- bug - compilation error
- bug - compilation warning
- bug - runtime error
- bug - runtime warning
- bug - logic error
Describe the bug
I'm already aware of the c++17 requirements but there seems to be a gray area where the std::filesystem library is ACTUALLY included in the c++ version. I had cmake print out the actual compiler command for me and I wasn't seeing stdc++17 or stdc++fs anywhere. Anytime I tried to build the examples or a test project using this I couldn't get it to figure out how to link in file system. I'm putting this here for alter in case anyone else has the same problem as me. I spent WAY too long trying to figure out how to do this properly in the cmake flow, and I'm too stupid to figure that out. I ended up just hacking the cmakefiles to get it to build.
From what I can tell there are a bunch of other issues related to the filesystem flow in this repo so maybe this will help answer some stuff. I'm not sure what the FindFilesystem.cmake
file is for either, I couldn't tell when it's supposed to run but I don't think it was.
diff --git a/cmake/functions/link_external_libraries.cmake b/cmake/functions/link_external_libraries.cmake
index c188265..2aa45fd 100644
--- a/cmake/functions/link_external_libraries.cmake
+++ b/cmake/functions/link_external_libraries.cmake
@@ -20,9 +20,9 @@ function(target_link_libraries_system target)
message("Warning: ${lib} doesn't set INTERFACE_INCLUDE_DIRECTORIES. No include_directories set.")
endif()
if(scope)
- target_link_libraries(${target} ${scope} ${lib})
+ target_link_libraries(${target} ${scope} ${lib} stdc++fs)
else()
- target_link_libraries(${target} ${lib})
+ target_link_libraries(${target} ${lib} stdc++fs)
endif()
endforeach()
endfunction(target_link_libraries_system)
Steps to Reproduce
mkdir build
cd build
cmake .. --install-prefix=/home/$USER/matplot_bin -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2"
make
# or any cmake args really, it seems pretty reproducible with my system, no matter what explatives I yell at my machine it won't use the correct CXX version/library
cmake .. -DCMAKE_RULE_MESSAGES:BOOL=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
Output
../../../source/matplot/libmatplot.a(gnuplot.cpp.o): In function `matplot::backend::gnuplot::output(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&)':
gnuplot.cpp:(.text+0x1995): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
gnuplot.cpp:(.text+0x19a4): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
gnuplot.cpp:(.text+0x1aa1): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
gnuplot.cpp:(.text+0x1aa9): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
gnuplot.cpp:(.text+0x1ae0): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
gnuplot.cpp:(.text+0x1ae8): undefined reference to `std::filesystem::create_directory(std::filesystem::__cxx11::path const&)'
gnuplot.cpp:(.text+0x1afd): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
gnuplot.cpp:(.text+0x1b05): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
gnuplot.cpp:(.text+0x1b41): undefined reference to `std::filesystem::__cxx11::path::parent_path() const'
../../../source/matplot/libmatplot.a(gnuplot.cpp.o): In function `matplot::backend::gnuplot::output(std::__cxx11::basic_string<char, std::char_traits<char>, std::
allocator<char> > const&)':
gnuplot.cpp:(.text+0x3d79): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
../../../source/matplot/libmatplot.a(gnuplot.cpp.o): In function `std::filesystem::__cxx11::path::extension() const':
gnuplot.cpp:(.text._ZNKSt10filesystem7__cxx114path9extensionEv[_ZNKSt10filesystem7__cxx114path9extensionEv]+0x11): undefined reference to `std::filesystem::__cxx1
1::path::_M_find_extension() const'
gnuplot.cpp:(.text._ZNKSt10filesystem7__cxx114path9extensionEv[_ZNKSt10filesystem7__cxx114path9extensionEv]+0xae): undefined reference to `std::filesystem::__cxx1
1::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/line_plot/plot/CMakeFiles/example_plot_1.dir/build.make:105: examples/line_plot/plot/example_plot_1] Error 1
make[1]: *** [CMakeFiles/Makefile2:3174: examples/line_plot/plot/CMakeFiles/example_plot_1.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
Platform
- cross-platform issue - linux
- cross-platform issue - windows
- cross-platform issue - macos
Environment Details:
- OS: Red Hat Enterprise Linux
- OS Version: 8.10
- Compiler: gcc/g++
- Compiler version: g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-21)
Additional context
I'm attempting to build and install