facebook / buck

A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.
https://buck.build
Apache License 2.0
8.56k stars 1.16k forks source link

Sample code does not build for Android #2675

Open Jacik opened 2 years ago

Jacik commented 2 years ago

Hi. I followed Getting Started guide on https://buck.build/setup/getting_started.html and try to build cross-platform-scale-2015-demo from https://github.com/fbsamples/bucksamples.git repository for Android. I have this error: toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc++

I tried NDK version 21 and 23 but still have the same error. I use buck installed on macOS via brew buck version 2021.01.12.01

BTW: I had to set fixed path to NDK 23 in .buckconfig because otherwise buck did not find NDK version 23 when using ANDROID_NDK_REPOSITORY. Only old 21 and 19 was found. Target NDK version 23.0.7599858 is not available. The following versions are available: 21.3.6528147, 19.0.5232133

I also tried to setup my own simple Android project with Buck. I add simple java class and jni library with one C file. When I build this project I have the same error.

Jacik commented 2 years ago

I have found that build out file buck-out/bin/common/hello#android-armv7,shared/linker.argsfile contains "-lc++_shared" It looks that buck is cutting this to only "-lc++"

-o
buck-out/gen/common/hello#android-armv7,shared/libcommon_hello.so
-target
armv7-none-linux-androideabi
-Wl,--build-id
-Wl,-z,noexecstack
-Wl,--gc-sections
-Wl,-z,defs
-Wl,-z,nocopyreloc
-Wl,--as-needed
-shared
-Wl,-soname
-Wl,libcommon_hello.so
buck-out/gen/common/hello#android-armv7,compile-pic-hello.c.o1f717d69/hello.c.o
-lc++_shared
Jacik commented 2 years ago

Hi. More findings. Error doesn't appear when using NDK 19. Error can be reproduce when using NDK 21. It looks that NDK 23 is not supported by buck because of different toolchain structure. I receive an error when using NDK 23 android-ndk-r23/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 doesn't exist.