Recently I am trying to use SiftGPU in Android. I am using the Linux. So, first I download a ndk and use the following code to get a standalone toolchain:
sudo sh ./build/tools/make-standalone-toolchain.sh --verbose --platform=android-15 --install-dir=/home/YourUserName/Downloads/my-tool --toolchain=arm-linux-androideabi-4.9
Then, I add the some codes to the CmakeLists.txt so it becomes:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(SIFTGPU C CXX)
set(NDK_STANDALONE_TOOLCHAIN /home/YourUserName/Downloads/my-tool/)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 15)
set(CMAKE_C_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-gcc)
set(CMAKE_CXX_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-g++)
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
set(CMAKE_FIND_ROOT_PATH ${NDK_STANDALONE_TOOLCHAIN})
add_definitions("--sysroot=${NDK_STANDALONE_TOOLCHAIN}/sysroot")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-deprecated -fPIC")
ADD_SUBDIRECTORY(src)
After that, I simply go to the directory of SiftGPU, create a new folder, enter it, and run:
cmake ..
Until now, everything seems ok. However, after I run the following command, well, unfortunately, it doesn't work:
make
And here is the error:
[ 9%] Building CXX object src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o
arm-linux-androideabi-g++: error: unrecognized argument in option '-march=core2'
arm-linux-androideabi-g++: note: valid arguments to '-march=' are: armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5e armv5t armv5te armv6 armv6-m armv6j armv6k armv6s-m armv6t2 armv6z armv6zk armv7 armv7-a armv7-m armv7-r armv7e-m armv7ve armv8-a armv8-a+crc iwmmxt iwmmxt2 native
arm-linux-androideabi-g++: error: unrecognized command line option '-mfpmath=sse'
src/SiftGPU/CMakeFiles/siftgpu.dir/build.make:62: recipe for target 'src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o' failed
make[2]: *** [src/SiftGPU/CMakeFiles/siftgpu.dir/FrameBufferObject.cpp.o] Error 1
CMakeFiles/Makefile2:103: recipe for target 'src/SiftGPU/CMakeFiles/siftgpu.dir/all' failed
make[1]: *** [src/SiftGPU/CMakeFiles/siftgpu.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
I tried to google it but I didn't get any useful result. It seems that the ndk complier is not compatible with SSE. Does anyone have any idea about this question?
Looks like their CMake files weren't meant to be cross-compiled.
arm-linux-androideabi-g++: error: unrecognized argument in option '-march=core2'
core2 is only valid for x86.
You'll need to take a look through SiftGPU's CMakeLists.txt to see if there are options for cross-compiling, and if not, just remove that flag.
Related
I am trying to use CMake to create a .so library that uses OpenCV for use on Android.
I have no prior experience with CMake before this. I got a couple things working with CMake so far. I successfully built and ran a simple OpenCV program for windows and I've also created a .so file that doesn't use OpenCV. I was able to successfully called that .so from a Unity program on Android. My goal is to create an OpenCV plugin for Unity. I turned to CMake because I tried making a simple .so in Visual Studios, but my Unity program couldn't find it (though I was able to create a .dll that used OpenCV for a windows Unity program using Visual Studios that worked).
I have both r19c Android NDK and OpenCV 4.5.2 Android SDK on my C drive.
My code file is test.cpp, and it very simply uses some OpenCV elements. It's as follows:
#include "opencv2/opencv.hpp"
extern "C" int get_number()
{
cv::Mat img(2,2, CV_8UC3, cv::Scalar(126,0,255));
cv::Size size = img.size();
int width = size.width;
return width;
}
I am thinking that my error may be in the CMakeLists.txt file, that I am probably pointing to the wrong OpenCV folders.
My CMakeLists.txt is:
cmake_minimum_required(VERSION 3.20)
set(OpenCV_DIR C:/OpenCVAndroid/sdk/native/jni/abi-arm64-v8a)
set(OpenCV_INCLUDE_DIRS C:/OpenCVAndroid/sdk/native/jni/include)
project( test )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_library( test SHARED test.cpp )
and I'm using a .bat file that has the following lines:
rmdir /s /q build
mkdir build
cd build
"C:/Program Files/CMake/bin/cmake.exe" ^
-S=C:\Users\m_knu\Desktop\test ^
-G"MinGW Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_TOOLCHAIN_FILE=C:\r19c\android-ndk-r19c\build\cmake\android.toolchain.cmake ^
-DCMAKE_MAKE_PROGRAM=C:\r19c\android-ndk-r19c\prebuilt\windows-x86_64\bin\make.exe ^
-DANDROID_NDK=C:\r19c\android-ndk-r19c ^
-DANDROID_NATIVE_API_LEVEL=android-21 ^
-DANDROID_ABI=arm64-v8a ^
-DCMAKE_MODULE_PATH="C:/OpenCVAndroid/sdk/native/jni/abi-armeabi-v7a" ^
"C:/Program Files/CMake/bin/cmake.exe" --build .
pause
all three files are located in the same folder.
When I run the .bat file I get the following output:
C:\Users\m_knu\Desktop\test>rmdir /s /q build
C:\Users\m_knu\Desktop\test>mkdir build
C:\Users\m_knu\Desktop\test>cd build
C:\Users\m_knu\Desktop\test\build>"C:/Program Files/CMake/bin/cmake.exe" -S=C:\Users\m_knu\Desktop\test -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:\r19c\android-ndk-r19c\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\r19c\android-ndk-r19c\prebuilt\windows-x86_64\bin\make.exe -DANDROID_NDK=C:\r19c\android-ndk-r19c -DANDROID_NATIVE_API_LEVEL=android-21 -DANDROID_ABI=arm64-v8a -DCMAKE_MODULE_PATH="C:/OpenCVAndroid/sdk/native/jni/abi-armeabi-v7a"
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/r19c/android-ndk-r19c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/r19c/android-ndk-r19c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: C:/OpenCVAndroid (found version "4.5.2")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/m_knu/Desktop/test/build
C:\Users\m_knu\Desktop\test\build>"C:/Program Files/CMake/bin/cmake.exe" --build .
[ 50%] Building CXX object CMakeFiles/test.dir/test.cpp.o
[100%] Linking CXX shared library libtest.so
CMakeFiles/test.dir/test.cpp.o: In function `get_number':
C:\Users\m_knu\Desktop\test/test.cpp:5: undefined reference to `cv::Mat::Mat(int, int, int, cv::Scalar_<double> const&)'
C:\Users\m_knu\Desktop\test/test.cpp:9: undefined reference to `cv::Mat::~Mat()'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libtest.so] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
C:\Users\m_knu\Desktop\test\build>pause
Press any key to continue . . .
As I mentioned earlier, my guess is that I've incorrectly referenced the OpenCV directories, but I wouldn't be surprised if I'm missing other things.
I want to run a simple executable that should print "Hello Cmake" when I will execute it from adb shell. For this, I have created a simple c++ file with CMakeLists.txt file as following:
hello.cpp
#include <iostream>
int main(int, char**) {
std::cout << "Hello, CMake!\n";
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
hello_cmake
# Sets the library as a static library.
STATIC
# Provides a relative path to your source file(s).
hello.cpp )
I have tried to run following command in terminal:
cmake D:/Development/CMAKE/HelloCmake/ -G Ninja \
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android29-clang++ \
-DANDROID_PLATFORM=29 \
-DCMAKE_CACHEFILE_DIR=D:/Development/CMAKE/HelloCmake/build \
-DCMAKE_MAKE_PROGRAM=D:/Sdk/cmake/3.10.2.4988404/bin/ninja.exe \
-DCMAKE_C_COMPILER=D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang \
-DCMAKE_CXX_COMPILER=D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang++
This has the following result:
D:\Development\CMAKE\HelloCmake>cmake D:/Development/CMAKE/HelloCmake/ -G Ninja -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android29-clang++ -DANDROID_PLATFORM=29 -DCMAKE_CACHEFILE_DIR=D:/Development/CMAKE/HelloCmake/build -DCMAKE_MAKE_PROGRAM=D:/Sdk/cmake/3.10.2.4988404/bin/ninja.exe -DCMAKE_C_COMPILER=D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang -DCMAKE_CXX_COMPILER=D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang++
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang
-- Check for working C compiler: D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang -- broken
CMake Error at D:/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"D:/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android29-clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/Development/CMAKE/HelloCmake/CMakeFiles/CMakeTmp
Run Build Command:"D:/Sdk/cmake/3.10.2.4988404/bin/ninja.exe" "cmTC_e4775"
ninja: fatal: CreateProcess: %1 is not a valid Win32 application.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "D:/Development/CMAKE/HelloCmake/CMakeFiles/CMakeOutput.log".
See also "D:/Development/CMAKE/HelloCmake/CMakeFiles/CMakeError.log".
D:\Development\CMAKE\HelloCmake>
Please help me to configure it correctly.
Update 1
With Michael guidance, I have found the build_command.txt file in Android Studio and it has the following contents for simple "Hello World" application:
Executable : D:\Sdk\cmake\3.10.2.4988404\bin\cmake.exe
arguments :
-HD:\Development\Android\HelloCPP\app\src\main\cpp
-BD:\Development\Android\HelloCPP\app\.cxx\cmake\debug\arm64-v8a
-DANDROID_ABI=arm64-v8a
-DANDROID_PLATFORM=android-26
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\Development\Android\HelloCPP\app\build\intermediates\cmake\debug\obj\arm64-v8a
-DCMAKE_BUILD_TYPE=Debug
-DANDROID_NDK=D:\Sdk\ndk\20.1.5948944
-DCMAKE_CXX_FLAGS=-std=c++14
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
-DCMAKE_SYSTEM_VERSION=26
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_ANDROID_NDK=D:\Sdk\ndk\20.1.5948944
-DCMAKE_TOOLCHAIN_FILE=D:\Sdk\ndk\20.1.5948944\build\cmake\android.toolchain.cmake
-G Ninja
-DCMAKE_MAKE_PROGRAM=D:\Sdk\cmake\3.10.2.4988404\bin\ninja.exe
jvmArgs :
I have run the following command for my application:
D:\Sdk\cmake\3.10.2.4988404\bin\cmake.exe
-HD:\Development\CMAKE\HelloCmake\
-BD:\Development\CMAKE\HelloCmake\arm64-v8a
-DANDROID_ABI=arm64-v8a
-DANDROID_PLATFORM=android-29
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\Development\CMAKE\HelloCmake\build
-DCMAKE_BUILD_TYPE=Debug
-DANDROID_NDK=D:\Sdk\ndk\20.1.5948944
-DCMAKE_CXX_FLAGS=-std=c++14
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
-DCMAKE_SYSTEM_VERSION=26
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_ANDROID_NDK=D:\Sdk\ndk\20.1.5948944
-DCMAKE_TOOLCHAIN_FILE=D:\Sdk\ndk\20.1.5948944\build\cmake\android.toolchain.cmake
-G Ninja
-DCMAKE_MAKE_PROGRAM=D:\Sdk\cmake\3.10.2.4988404\bin\ninja.exe
and I get the following output:
D:\Development\CMAKE\HelloCmake>D:\Sdk\cmake\3.10.2.4988404\bin\cmake.exe -HD:\Development\CMAKE\HelloCmake\ -BD:\Development\CMAKE\HelloCmake\arm64-v8a -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-29 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\Development\CMAKE\HelloCmake\build -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=D:\Sdk\ndk\20.1.5948944 -DCMAKE_CXX_FLAGS=-std=c++14 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_VERSION=26 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_ANDROID_NDK=D:\Sdk\ndk\20.1.5948944 -DCMAKE_TOOLCHAIN_FILE=D:\Sdk\ndk\20.1.5948944\build\cmake\android.toolchain.cmake -G Ninja -DCMAKE_MAKE_PROGRAM=D:\Sdk\cmake\3.10.2.4988404\bin\ninja.exe
-- Check for working C compiler: D:/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: D:/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: D:/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Development/CMAKE/HelloCmake/arm64-v8a
D:\Development\CMAKE\HelloCmake>
Build files are written to arm64-v8a but I didn't find any ELF shared object, 64-bit LSB arm64, dynamic (/system/bin/linker64), stripped object that should be able to run on my android device.
I have found only the following files:
$ find . | xargs file | grep ELF
./CMakeFiles/3.10.2/CMakeDetermineCompilerABI_C.bin: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, BuildID[sha1]=7cb1fddcd4776716628feaf37d471c1ea4a55314, with debug_info, not stripped
./CMakeFiles/3.10.2/CMakeDetermineCompilerABI_CXX.bin: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, BuildID[sha1]=1f498297f62e5a52751312894e88a9abef0412d5, with debug_info, not stripped
./CMakeFiles/feature_tests.bin: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, BuildID[sha1]=a56baeb98e3f077c3cc0a512b0535089a717929c, with debug_info, not stripped
Any suggestion?
Update 2
I have run D:\Sdk\cmake\3.10.2.4988404\bin\ninja.exe -C arm64-v8a command to make the target static library but I get libhello_cmake.a which is current ar archive.
I think to make an executable the CMakeLists.txt add_library line should be replaced with something else?
There are a couple of problems:
Static libraries are not meant to be run directly. If you want to build an executable that you can run, you should use add_executable instead of add_library.
When you invoke cmake you should set the CMAKE_TOOLCHAIN_FILE option to specify the toolchain file to use, and possibly other options as well. To get an idea of what Android Studio / Gradle uses, you can use Android Studio's project wizard to create an Android project with C++ support and take a look at the cmake_build_command.txt file that gets generated when you build that project.
After running cmake you also need to run ninja. The command would be something like ninja -C <directory containing build files generated by cmake>.
I'm trying to cross-compile LLVM for the Android NDK, but my CMake invocation is failing. I'm using Ubuntu 16.04.
I've downloaded the LLVM source code (llvm version 3.8) and Android NDK (downloaded to a mounted disk, if that matters), and I've followed the instructions given in the Android.cmake file in [path to LLVM Source]/cmake/platforms:
# Android.cmake
# Toolchain config for Android NDK.
# This is expected to be used with a standalone Android toolchain (see
# docs/STANDALONE-TOOLCHAIN.html in the NDK on how to get one).
#
# Usage:
# mkdir build; cd build
# cmake ..; make
# mkdir android; cd android
# cmake -DLLVM_ANDROID_TOOLCHAIN_DIR=/path/to/android/ndk \
# -DCMAKE_TOOLCHAIN_FILE=../../cmake/platforms/Android.cmake ../..
# make <target>
SET(CMAKE_SYSTEM_NAME Linux)
IF(NOT CMAKE_C_COMPILER)
SET(CMAKE_C_COMPILER /usr/bin/clang)
ENDIF()
IF(NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER /usr/bin/clang++)
ENDIF()
SET(ANDROID "1" CACHE STRING "ANDROID" FORCE)
SET(ANDROID_COMMON_FLAGS "-target arm-linux-androideabi --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot -B${LLVM_ANDROID_TOOLCHAIN_DIR}")
SET(CMAKE_C_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
SET(CMAKE_CXX_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS "-pie" CACHE STRING "toolchain_exelinkflags" FORCE)
But the error I get when invoking CMake as cmake -DLLVM_ANDROID_TOOLCHAIN_DIR=/media/alvin/Windows8_OS/Android/Sdk/ndk-bundle -DCMAKE_TOOLCHAIN_FILE=../llvm-3.8.0.src/cmake/platforms/Android.cmake ../llvm-3.8.0.src is:
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/clang" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /media/alvin/Windows8_OS/LLVM/and-build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_1e02b/fast"
/usr/bin/make -f CMakeFiles/cmTC_1e02b.dir/build.make
CMakeFiles/cmTC_1e02b.dir/build
make[1]: Entering directory
'/media/alvin/Windows8_OS/LLVM/and-build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_1e02b.dir/testCCompiler.c.o
/usr/bin/clang -target arm-linux-androideabi
--sysroot=/media/alvin/Windows8_OS/Android/Sdk/ndk-bundle/sysroot
-B/media/alvin/Windows8_OS/Android/Sdk/ndk-bundle -o
CMakeFiles/cmTC_1e02b.dir/testCCompiler.c.o -c
/media/alvin/Windows8_OS/LLVM/and-build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_1e02b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1e02b.dir/link.txt
--verbose=1
/usr/bin/clang -target arm-linux-androideabi
--sysroot=/media/alvin/Windows8_OS/Android/Sdk/ndk-bundle/sysroot
-B/media/alvin/Windows8_OS/Android/Sdk/ndk-bundle -pie
CMakeFiles/cmTC_1e02b.dir/testCCompiler.c.o -o cmTC_1e02b -rdynamic
/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux
elf_l1om elf_k1om i386pep i386pe
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
CMakeFiles/cmTC_1e02b.dir/build.make:97: recipe for target 'cmTC_1e02b'
failed
make[1]: *** [cmTC_1e02b] Error 1
make[1]: Leaving directory
'/media/alvin/Windows8_OS/LLVM/and-build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_1e02b/fast' failed
make: *** [cmTC_1e02b/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:54 (project)
It seems that there's a problem when linking: "clang: error: linker command failed with exit code 1", but I have no idea how to fix this. Does anyone have any insight on how to fix this problem?
EDIT: I'm using clang-3.8 and llvm source version 3.8 if that matters.
I am trying to build msm-3.18 kernel for msm8996 (Android 8.0.0).
When trying to build from Android source top directory, it fails on running tests.
Following is the trace
FAILED: out/soong/.bootstrap/soong-cc-config/test/test.passed
out/soong/.bootstrap/bin/gotestrunner -p ./build/soong/cc/config -f out/soong/.bootstrap/soong-cc-config/test/test.passed -- \ out/soong/.bootstrap/soong-cc-config/test/test -test.short
panic: read /home/vagrant/android-msm: is a directory
goroutine 1 [running]:
android/soong/cc/config.setSdclangVars()
/home/vagrant/android-msm/build/soong/cc/config/global.go:197 +0x20d4
android/soong/cc/config.init.2()
/home/vagrant/android-msm/build/soong/cc/config/global.go:169 +0xcc9
android/soong/cc/config.init()
/home/vagrant/android-msm/build/soong/cc/config/tidy_test.go:42 +0x3969
main.init()
/home/vagrant/android-msm/out/soong/.bootstrap/soong-cc-
config/test/test.go:34 +0x4e
ninja: build stopped: subcommand failed.
15:22:17 soong bootstrap failed with: exit status 1
make: *** [run_soong_ui] Error 1
make: Leaving directory `/home/vagrant/android-msm'
I guess it has something to do with $SDCLANG_PATH but I need help
You need to register on Qualcomm Developer Network and download their proprietary compiler.
According to instruction on their forum:
Download the Qualcomm LLVM Compiler here: https://developer.qualcomm.com/download/sdllvm/snapdragon-llvm-compiler-android-linux64.tar.gz
Extract Snapdragon-llvm-3.8.4-toolchain.tar.gz
Move toolchains\llvm-Snapdragon_LLVM_for_Android_3.8\prebuilt\linux-x86_64 to prebuilts/clang/host/linux-x86/sdclang-3.8 within your Android build environment.
Add the following lines to your device's BoardConfig:
ifneq ($(HOST_OS),darwin)
SDCLANG := true
SDCLANG_PATH := prebuilts/clang/host/linux-x86/sdclang-3.8/bin
SDCLANG_LTO_DEFS := device/qcom/common/sdllvm-lto-defs.mk
endif
Compile Android.
Here is instruction from their forum: https://developer.qualcomm.com/forum/qdn-forums/software/snapdragon-llvm-compiler-android/33437
I am trying to cross-compile GLibC 2.24 for ARM (Android) with the gcc-arm-linux-androideabi compiler. Here is the ./configure syntax I used:
../glibc-2.24/configure --prefix=/usr --host=arm-linux-androideabi --with-headers=/usr/include
However, when I run make, it fails with the following error:
In file included from
../sysdeps/arm/libc-tls.c:19:0:
../csu/libc-tls.c: In function '__libc_setup_tls':
../csu/libc-tls.c:191:1: error: '__ARM_NR_set_tls' undeclared (first use in this function)
../csu/libc-tls.c:191:1: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/home/red/glibc-build/csu/libc-tls.o] Error 1
make[2]: Leaving directory `/home/red/glibc-2.24/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/home/red/glibc-2.24'
make: *** [all] Error 2
I browsed the web on why it happened, didn't find anything. What could be the cause of this error?
I am running Ubuntu 14.04.5 LTS 64-bit.
I am running Ubuntu 14.04.5 LTS 64-bit.
That is a meaningless statepement. 64-bit what? Is it sparc64, aarch64, x86_64, something else?
Most likely you are using x86_64. In that case, you are using configure all wrong. The --host=arm-linux-androideabi tells configure that you are building on an ARM linux machine, which couldn't be further from the truth.
What you likely mean is that you want to build for arm-linux-androideabi target, and in that case the correct configure command is something like:
configure --target=arm-linux-androideabi --prefix=/usr ...
Your --with-headers setting is also very likely to be incorrect: you almost certainly don't want to use /usr/include from x86_64 host to build for arm target.