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

Arch linux clang doesn't find standard library headers #104

Closed
joejoepie opened this issue Aug 16, 2018 · 16 comments
Closed

Arch linux clang doesn't find standard library headers #104

joejoepie opened this issue Aug 16, 2018 · 16 comments
Labels
bug Something isn't working linux Issue/feature request for Linux only

Comments

@joejoepie
Copy link

joejoepie commented Aug 16, 2018

Describe the bug
With standard clang version 6.0.1 and gcc version 8.2.1 (delivers std lib on arch) there is an issue of clang complaining that he does not find following headers:

  • string
  • map
  • cmath
  • functional
  • limits

When compiling self written programs these issues do not occur. I've tried to edit the CMakeLists.txt by adding the include_directories where these files reside. This works, but then multiple files complain about an undeclared identifier "strlen".
I suppose the issue resides in customizing parameters when executing clang.

The cmake generator line i use is provided in your build guide:
CC=/usr/bin/clang CXX=/usr/bin/clang++ \ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../debug/filament ../..

This happens on a standard clean install of arch linux with the newest version of clang and gcc.

@romainguy
Copy link
Collaborator

Thanks for the report. Do you have libc++-dev installed? We require the use of clang and of the clang STL. Based on the error you're describing it sounds like you don't have libc++dev. The README has more information on the prerequisites.

@romainguy romainguy added linux Issue/feature request for Linux only bug Something isn't working labels Aug 16, 2018
@joejoepie
Copy link
Author

Let me inform you that Arch linux has no such package. Clang in arch uses the gcc standard library by default if i'm not mistaken.

@romainguy
Copy link
Collaborator

That may be but our code doesn't compile with GCC's standard library.

@joejoepie
Copy link
Author

Ok then it's a personal problem of mine, and i'll try to fix it. Just consider this a headsup than that your project does not compile on arch linux out of the box.

@romainguy
Copy link
Collaborator

I definitely appreciate the heads up. I'll investigate a bit more and try to find the package name for arch Linux to update our readme.

@romainguy
Copy link
Collaborator

libc++ might be available under the name libcxx. AUR has a libc++ apparently.

@joejoepie
Copy link
Author

Building it now, i'll get back to you with results. My mistake that i didn't check that out before creating an issue.

@romainguy
Copy link
Collaborator

No need to apologize, I know it would be a lot easier if it worked with any combination of gcc/clang/libstdc++/libc++ :)

@joejoepie
Copy link
Author

Thank you my friend! It compiles now :) Sorry for wasting your time. I'm excited to explore your engine ;)

@romainguy
Copy link
Collaborator

Glad you were able to get it to compile, don't hesitate if you run into other issues!

@krzysztofsroga
Copy link

I also can't build it on Arch due to libc++ problem
I installed the libc++ package from AUR so in my /usr/lib/ directory I see files:

-rwxr-xr-x  1 root root       28 Aug 25 12:18 libc++.so
lrwxrwxrwx  1 root root       13 Aug 25 12:18 libc++.so.1 -> libc++.so.1.0
-rwxr-xr-x  1 root root   849936 Aug 25 12:18 libc++.so.1.0

I can run examples from Clion, but when I try to build release(no matter if it's via build.sh file or CMake/Ninja) then I get:

/usr/bin/ld: cannot find -lc++
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)

@UberLambda
Copy link

UberLambda commented Sep 1, 2018

Same as @wefhy, I have both libc++ and libc++abi installed from the AUR (on Manjaro) but ld still can't find -lc++.

@eduardobraun
Copy link

I have the same problem with Arch and the libc++ from AUR.

Building with ./build release says that ld cannot find -lc++.

But if I try ld -lc++ --verbose then ld finds libc++:

attempt to open /usr/x86_64-pc-linux-gnu/lib64/libc++.so failed
attempt to open /usr/x86_64-pc-linux-gnu/lib64/libc++.a failed
attempt to open /usr/lib/libc++.so succeeded
...

Maybe It's something to do with how ninja finds the libraries, I don't really know how ninja works. I think I'll try to build using a Docker image when I have the time.

@lasagnaphil
Copy link

lasagnaphil commented Mar 5, 2019

I don't think Ninja is a problem here, because the same thing has happened to me when using make (using the -m option).

Right now, the Manjaro repository hosts a libc++ / libc++abi package, but it does not include static libs. To fix this, you need to clone the PKGBUILD from the manjaro package Git repo (https://gitlab.manjaro.org/packages/community/libcxx.git), add the option options=('staticlibs') for the functions package_libc++() and package_libc++abi() in the PKGBUILD, and install it manually using makepkg -si --nocheck.

However, even when the libc++ static libraries are detected, it seems like there are still some problems left. I get a lot of linker errors, such as:

(.text._ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr+0x63): undefined reference to `__cxa_allocate_exception'
/usr/bin/ld: (.text._ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr+0x7d): undefined reference to `__cxa_guard_acquire'
/usr/bin/ld: (.text._ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr+0xc3): undefined reference to `__cxa_guard_release'
/usr/bin/ld: (.text._ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr+0xed): undefined reference to `__cxa_throw'
/usr/bin/ld: (.text._ZNSt3__17promiseIvE28set_exception_at_thread_exitESt13exception_ptr+0xfd): undefined reference to `__cxa_free_exception'

I thought maybe there are some incompatibilities between my current system's clang and libc++. But then I've checked that the two are both version 7.0.1. I am still investigating this error...

@lasagnaphil
Copy link

lasagnaphil commented Mar 5, 2019

Finally solved the problem!

To compile release builds in Arch Linux (or Manjaro), you need to also link libc++abi. You need to use the flag FILAMENT_REQUIRES_CXXABI=ON when running build.sh. (Reading the project's CMakeLists.txt file, this flag was originally intended for CI environments...)

EDIT: exactly the same solution as #16...

@romainguy
Copy link
Collaborator

Thanks for the report! Note that this workaround is mentioned in the README.md file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linux Issue/feature request for Linux only
Projects
None yet
Development

No branches or pull requests

6 participants