Creating android-go "stdlib.h: No such file or directory"

I am trying to create an android-go example in ubuntu 16 using .. / build -android.sh, but I get an error message,

# runtime/cgo
_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^

https://github.com/xlab/android-go/tree/master/examples/minimal

Does anyone have any suggestions? I already double checked the lib6c library libraries.

Complete build log

../build-android.sh 
+ : 26
+ : /home/jsper/Downloads
+ : /home/jsper/Downloads/ndk-bundle
+ export ANDROID_API ANDROID_HOME ANDROID_NDK_HOME
+ /home/jsper/Downloads/tools/bin/sdkmanager --update
[=======================================] 100% Computing updates...             
+ /home/jsper/Downloads/tools/bin/sdkmanager ndk-bundle
[=======================================] 100% Computing updates...             
+ rm -rf android/toolchain
+ /home/jsper/Downloads/ndk-bundle/build/tools/make_standalone_toolchain.py --install-dir=android/toolchain --arch=arm --api=26 --stl=libc++
+ rm -rf android/toolchain/sysroot/usr
+ cp -r /home/jsper/Downloads/ndk-bundle/platforms/android-26/arch-arm/usr android/toolchain/sysroot/usr
+ mkdir -p android/app/src/main/jniLibs/armeabi-v7a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go get -d
+ CC=/home/jsper/go/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc
+ CXX=/home/jsper/go/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-g++
+ CGO_ENABLED=1
+ CGO_CFLAGS=-march=armv7-a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go build -i -buildmode=c-shared -o android/app/src/main/jniLibs/armeabi-v7a/libgomain.so
# runtime/cgo
_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
+4
source share
3 answers

I never received the answer that allowed me to build the project, so I'm going to send my own answer.

+1
source

Have you installed the package you need to build? As I read, lib sometimes does not install properly. Thus, reinstallation may help.

Try:

sudo apt-get update
sudo apt-get install build-essential
+3
source

https://github.com/xlab/android-go/tree/master/examples/minimal :

compileSdkVersion = 25
buildToolsVersion = '25.0.0'

at https://github.com/xlab/android-go/blob/master/examples/minimal/android/app/build.gradle

You are using 26

/home/jsper/Downloads/ndk-bundle/build/tools/make_standalone_toolchain.py --install-dir=android/toolchain --arch=arm --api=26 --stl=libc++

you need to install NDK with the correct version

+3
source

Source: https://habr.com/ru/post/1693705/


All Articles