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

Fix build errors due to missing dependency stdc++fs #33

Merged
merged 2 commits into from
Jun 22, 2021
Merged

Fix build errors due to missing dependency stdc++fs #33

merged 2 commits into from
Jun 22, 2021

Conversation

mbrunnen
Copy link
Contributor

@mbrunnen mbrunnen commented Jun 22, 2021

I had errors when linking:

[ 67%] Linking CXX executable inkcpp_cl
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.cpp.o: in function `test_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
test.cpp:(.text+0x12c7): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
/usr/bin/ld: test.cpp:(.text+0x13d2): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.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)':
test.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: CMakeFiles/inkcpp_cl.dir/test.cpp.o: in function `std::filesystem::__cxx11::operator==(std::filesystem::__cxx11::path const&, std::filesystem::__cxx11::path const&)':
test.cpp:(.text._ZNSt10filesystem7__cxx11eqERKNS0_4pathES3_[_ZNSt10filesystem7__cxx11eqERKNS0_4pathES3_]+0x1f): undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.cpp.o: in function `std::filesystem::__cxx11::path::extension() const':
test.cpp:(.text._ZNKSt10filesystem7__cxx114path9extensionEv[_ZNKSt10filesystem7__cxx114path9extensionEv]+0x19): undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const'
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.cpp.o: in function `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&)':
test.cpp:(.text._ZNSt10filesystem7__cxx1118directory_iteratorC2ERKNS0_4pathE[_ZNSt10filesystem7__cxx1118directory_iteratorC5ERKNS0_4pathE]+0x26): undefined reference to `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)'
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.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)':
test.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()'
/usr/bin/ld: CMakeFiles/inkcpp_cl.dir/test.cpp.o: in function `std::filesystem::__cxx11::path::path<char [5], std::filesystem::__cxx11::path>(char const (&) [5], std::filesystem::__cxx11::path::format)':
test.cpp:(.text._ZNSt10filesystem7__cxx114pathC2IA5_cS1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5IA5_cS1_EERKT_NS1_6formatE]+0x5e): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
make[2]: *** [inkcpp_cl/CMakeFiles/inkcpp_cl.dir/build.make:101: inkcpp_cl/inkcpp_cl] Error 1
make[1]: *** [CMakeFiles/Makefile2:254: inkcpp_cl/CMakeFiles/inkcpp_cl.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

My compiler:

Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)

Adding stdc++fs as library solved the issue.

@JBenda
Copy link
Owner

JBenda commented Jun 22, 2021

Thanks, we some how never spotted it.
Which compiler was you using?

@mbrunnen
Copy link
Contributor Author

Thanks, we some how never spotted it.
Which compiler was you using?

Strange. I am using GCC 8.3.0:

Package: gcc
Version: 4:8.3.0-1
Priority: optional
Build-Essential: yes
Section: devel
Source: gcc-defaults (1.181)
Maintainer: Debian GCC Maintainers <[email protected]>
Installed-Size: 46.1 kB
Provides: c-compiler, gcc-x86-64-linux-gnu (= 4:8.3.0-1)
Depends: cpp (= 4:8.3.0-1), gcc-8 (>= 8.3.0-1~)
Recommends: libc6-dev | libc-dev
Suggests: gcc-multilib, make, manpages-dev, autoconf, automake, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Tag: devel::compiler, devel::lang:c, devel::library, implemented-in::c,
 interface::commandline, role::devel-lib, role::metapackage,
 role::program, suite::gnu, works-with::software:source
Download-Size: 5,196 B
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian buster/main amd64 Packages
Description: GNU C compiler
 This is the GNU C compiler, a fairly portable optimizing compiler for C.
 .
 This is a dependency package providing the default GNU C compiler.

@mbrunnen
Copy link
Contributor Author

Ok, I looked a bit into it and found this:

https://en.cppreference.com/w/cpp/filesystem#Notes:

Notes
Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs.

So, requiring a minimum compiler version in cmake would also do the trick.

Copy link
Owner

@JBenda JBenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for the research.
But why the different between public/private for GNU and clang?

Repository owner locked and limited conversation to collaborators Jun 22, 2021
Repository owner unlocked this conversation Jun 22, 2021
@JBenda JBenda merged commit 7c55a1a into JBenda:master Jun 22, 2021
@JBenda
Copy link
Owner

JBenda commented Jun 22, 2021

Thanks for the PR.
If you have questions or ideas feel free to contact me. Or look in the c-port channel of the inkle Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants