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 error: [...]../arm-linux-androideabi/bin/ld: error: cannot find -lc++ #707

Yetangitu opened this issue Jan 10, 2020 · 3 comments


Copy link

@Yetangitu Yetangitu commented Jan 10, 2020

I'm working my way through building mpd for Android to target older devices (now at 4.4 - kitkat) as the available APK's all seem to target 5.0 and higher. After gleaning the build incantation from FDroid (since this is not described in the documentation as far as I can see?) it goes mostly OK until it hits a wall in trying to link

/home/frank/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ \
 -o  <lots_of_stuff/>  -Wl,-rpath-link,/var/src/MPD/MPD/output/android/src/java

/home/frank/Android/Sdk/ndk/20.1.5948944/toolchains/arm-linux-androideabi-4.9/ \
prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x \
/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc++

Is this a known problem, possibly related to my attempt to build for a lower API level? The ndk does contain prebuilt versions of the needed library, albeit with versioned names:

ls  /home/frank/Android/Sdk/ndk/20.1.5948944/ \
libandroid_support.a  libc++.a.20  libc++.a.25      libc++_static.a
libc++.a.16           libc++.a.21  libc++.a.26      libc++abi.a
libc++.a.17           libc++.a.22  libc++.a.27      libunwind.a
libc++.a.18           libc++.a.23  libc++.a.28
libc++.a.19           libc++.a.24  libc++.a.29

...and it has the right search path set to find them... but it won't. There is no direct reference to libc++ in the linker invocation so is infers this dependency from one of the linked files - which is unclear.


This comment has been minimized.

Copy link

@Yetangitu Yetangitu commented Jan 11, 2020


Probably related, some of the comments are Stop passing --sysroot (android/ndk#951 (comment)) and Don't pass -gcc-toolchain (android/ndk#951 (comment)) as well as some general comments on how this situation can arise in android/ndk#951 (comment):

I think there are two ways that you can get into this state:

  • You've only partially migrated to the new toolchain format. That seems to be what the OP has done (please correct me if I'm wrong; I'm relying on command line forensics with that guess) by switching to the triple-prefixed Clangs, but still keeping all the old flags. Partial migrations are very likely to run into these sorts of problems, and it's best to just clean up all your flags at the same time.
  • You haven't started migrating at all, but now your build is broken. Presumably the reason this happens because your build wasn't passing -nostdlib++ in prior releases. This flag is fairly new and the result of not passing it was fairly innocuous (even ndk-build and the CMake toolchain didn't do this until somewhat recently), so it was easy to forget. However it's something that you should be using if you're manually linking libc++. If you just add that flag that should let you continue using NDK r20 without more involved modifications to your build system (though you'll want to start looking into this soon, I'm guessing that r22 will be the release that does away with the legacy paths)._

This comment has been minimized.

Copy link

@Yetangitu Yetangitu commented Jan 11, 2020

More FYI, the build succeeds when using NDK v18.1 so this problem is related to the issue mentioned above.


This comment has been minimized.

Copy link

@MaxKellermann MaxKellermann commented Jan 17, 2020

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.