Did anyone implemeted Cricket audio engine (http://www.crickettechnology.com/blog/) for Android Studio using gradle and Cmake (Android NDK) ?
I have imported the lib in my Cmake like this:
target_link_libraries(test
${CMAKE_CURRENT_SOURCE_DIR}/../../test/cricketaudio/lib/libck.a)
And the compiler sees it alright but when I try to run it, the linker gives me this error:
Error while executing process
[1/1] Linking CXX shared library
..\..\..\..\build\intermediates\cmake\development\debug\obj\armeabi-
v7a\libtest.so
FAILED: cmd.exe -soname,libtest.so -o
..\..\..\..\build\intermediates\cmake\development\debug\obj\armeabi-
v7a\libtest.so #CMakeFiles/test.rsp && cd ."
core/system_android.cpp:174: error: undefined reference to
'android_getCpuFamily'
core/system_android.cpp:187: error: undefined reference to
'android_getCpuFeatures'
core/system_android.cpp:210: error: undefined reference to
'android_getCpuCount'
clang++.exe: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.
I am aware that libck (cricket audio) has a dependency lib the Android NDK cpufeauters lib which is located in the Android NDK bundle (Android\Sdk\ndk-bundle\sources\android\cpufeatures).
I don`t know how to make this cpufeatures lib visible to the Linker of my project ???
Any help or pointers would be appreciated.
I have simply included the cpu-features.c and header file to my cmakelist and now it works :).
Related
description
We have a C/C++ project wallet-core that is using third party library libsecp256k1, and we install libsecp256k1 into /usr/local/lib and /usr/local/include, all works well in wallet-core Unit Test, till we add it to android, which call wallet-core.
call links:
android project -> wallet-core -> trezor_crypto -> libsecp256k1
When we run tools/android-test, got error in link period:
xxxx -L/usr/local/lib trezor-crypto/libTrezorCrypto.a libprotobuf.a -llog /usr/local/lib/libsecp256k1.a -latomic -lm && :
/Users/bibodeng/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /usr/local/lib/libsecp256k1.a: no archive symbol table (run ranlib)
../../../../../../trezor-crypto/src/ecdsa.c:1211: error: undefined reference to 'secp256k1_context_create'
../../../../../../trezor-crypto/src/ecdsa.c:1213: error: undefined reference to 'secp256k1_schnorr_sign'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Configuring for JNI
two function is undefined and there is no symbols, tell me ranlib. ranlib result:
$ranlib libsecp256k1.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive member: libsecp256k1.a(/0) size too large (archive member extends past the end of the file)
I run nm -g libsecp256k1.a also said it's truncated or malformed archive.
Please help me to solve this problem, we have stuck several days. Thanks a lot.
guess reason
I read many answer and guess it's reason:
linker will run ranlib before link, but it fail cause there is no
symbol ranlib failed because libsecp256k1.a
archive file is too big or maybe not in good format
libsecp256k1.a file is not
generated well or ranlib has problems.
codes & config
libsecp256k1: https://github.com/Bitcoin-ABC/secp256k1
./autogen.sh
mkdir build
cd build
../configure --enable-module-schnorr
make
make check
sudo make install
wallet-core: https://github.com/IFWallet/wallet-core/tree/free_cash
git clone git#github.com:IFWallet/wallet-core.git
git checkout free_cash
cd wallet-core
./bootstrap.sh
./tools/android-test
download the codes from github and checkout free_cash branch, run upper cmd will get the same error.
relate answers
I already try this answer, but not work.
ndk-no-archive-symbol-table
I am trying to compile a CMake project for android.
I use QtCreator to create and compile the project. Using QMake works fine, but CMake projects don't work.
CMake Project parsing failed.
Running "C:\Android\android-sdk\cmake\3.10.2.4988404\bin\cmake.exe -E server "--pipe=\\.\pipe\{78eb9a25-fbdf-4ac7-b840-8cfe89cbd883}" --experimental" in C:\Users\Thorsten\AppData\Local\Temp\QtCreator-Zmienl\qtc-cmake-KUabkXqG.
Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe", "-DCMAKE_C_COMPILER:STRING=C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe", "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.13.0/android_x86_64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.13.0/android_x86_64/bin/qmake.exe".
The CXX compiler identification is Clang 8.0.2
Check for working CXX compiler: C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
Check for working CXX compiler: C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- broken
CMake Error at C:/Android/android-sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"C:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeTmp
Run Build Command:"C:/Android/android-sdk/cmake/3.10.2.4988404/bin/ninja.exe" "cmTC_622f7"
[1/2] Building CXX object CMakeFiles/cmTC_622f7.dir/testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_622f7.exe
FAILED: cmTC_622f7.exe
cmd.exe /C "cd . && C:\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe CMakeFiles/cmTC_622f7.dir/testCXXCompiler.cxx.obj -o cmTC_622f7.exe -Wl,--out-implib,libcmTC_622f7.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
Configuring incomplete, errors occurred!
See also "C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Thorsten/AppData/Local/Temp/QtCreator-Zmienl/qtc-cmake-KUabkXqG/CMakeFiles/CMakeError.log".
CMake Project parsing failed.
I found several posts about this, but most of them were not answered or simply not useful. I found this helpful, so I added
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
before project(). But now I get
CMake Error in CMakeLists.txt:
No known features for CXX compiler
"Clang"
version 8.0.2.
CMake Project parsing failed.
So far I haven't found something useful for that.
I hope I can get some more help this way.
ps: I recently reinstalled my os (Windows 10), so if I forgot to update something it's not older than two month. I let QtCreator, Visual Studio and Android Studio do the installation of the toolchains.
pps: The project is a new project created by QtCreator
I am trying to build an Android project using the android NDK.
I have added the NDK to the QT Versions, the build kit was auto detected but when running CMake I get the following error:
Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-g++", "-DCMAKE_C_COMPILER:STRING=/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc", "-DCMAKE_PREFIX_PATH:STRING=/home/self/Qt5.9.6/5.9.6/android_x86", "-DQT_QMAKE_EXECUTABLE:STRING=/home/self/Qt5.9.6/5.9.6/android_x86/bin/qmake".
The C compiler identification is GNU 4.9.0
The CXX compiler identification is GNU 4.9.0
Check for working C compiler: /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
Check for working C compiler: /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/ninja" "cmTC_991f8"
[1/2] Building C object CMakeFiles/cmTC_991f8.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_991f8
FAILED: cmTC_991f8
: && /home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc -rdynamic CMakeFiles/cmTC_991f8.dir/testCCompiler.c.o -o cmTC_991f8 && :
/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot open crtend_android.o: No such file or directory
/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -lc
/home/self/Downloads/addis/android-ndk-r17b/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -ldl
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
Configuring incomplete, errors occurred!
See also "/tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeOutput.log".
See also "/tmp/QtCreator-Tuub3S/qtc-cmake-XXSZ1kmJ/CMakeFiles/CMakeError.log".
CMake Project parsing failed.
What am I doing wrong?
EDIT So as suggested I downloaded NDK 10e ... Problem seems to stay the same:
/usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52: error: The C compiler "/home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc" is not able to compile a simple test program.
It fails with the following output: Change Dir: /tmp/QtCreator-vkcYcW/qtc-cmake-XXyT08En/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/ninja" "cmTC_3ab69"
[1/2] Building C object CMakeFiles/cmTC_3ab69.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_3ab69 FAILED: cmTC_3ab69 : && /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc -rdynamic CMakeFiles/cmTC_3ab69.dir/testCCompiler.c.o -o cmTC_3ab69 && :
/home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-androi.d/4.9/../../../../i686-linux-android/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot open crtend_android.o: No such file or directory /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -lc /home/self/Android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -ldl
collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
Qt does not support a recent version of NDK, in the docs it is recommended to use NDK 10e
I'm trying to build poco and cegui libs with crystax ndk(version 10.3.2) using cmake
export ANDROID_NDK=/.../crystax-ndk-10.3.2
cmake -DPOCO_STATIC=ON -DCMAKE_TOOLCHAIN_FILE="../../AndroidBuildToolchain/android.toolchain.cmake" -DANDROID_ABI=x86 -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_TOOLCHAIN_NAME=x86-4.9 ../..
and build my own app with android.mk and I got the same error(using ndk-build):
crystax-ndk-10.3.2/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld: error: cannot find -lcrystax
And other link errors from, like these
error: undefined reference to 'sinf'
error: undefined reference to 'cosf'
error: undefined reference to '__getCurrentRuneLocale'
But when i'm trying to build the poco and my project with google NDK it works good. But I have reasons to use crystax. So, can anybody help me to find out the reason of these errors?
I've tried -lm flag for math(sin,cos) lib, but I had the same errors.
UPDATE March 19, 2016: Superpowered has released new binaries which work properly with NDK r11
I'm trying to build Superpowered library CrossExample sample project in Android Studio. Until recent NDK update it worked like charm, but now execution of ndk-build gives an error:
Error:error: undefined reference to '__page_size'
I tried building with different toolchains, removing/adding several build flags with no luck so far.
In a different project that uses Superpowered SDK and pretty much the same config I get some other error details. Part of output message log:
/android/ndk/platforms/android-9/arch-x86/usr/include/unistd.h:173: error: undefined reference to '__page_size'
/android/ndk/platforms/android-9/arch-x86/usr/include/unistd.h:173: error: undefined reference to '__page_size'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/user_name/StudioProjects/project_name/app/src/main/jniSuperpowered/obj/local/x86/libNativeLibName.so] Error 1
make: *** Waiting for unfinished jobs....
/Volumes/iMect/iphone/SuperpoweredSource/decoder/SuperpoweredDecoder.cpp:120: error: undefined reference to '__page_size'
/Volumes/iMect/iphone/SuperpoweredSource/decoder/hlsreader.cpp:582: error: undefined reference to '__page_size'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/user_name/StudioProjects/project_name/app/src/main/jniSuperpowered/obj/local/armeabi-v7a/libNightcorizerSuperpowered.so] Error 1
FAILURE: Build failed with an exception.
What looks not right is undefined reference to __page_size in unistd.h . However I've got very little idea of further troubleshooting.
Thanks ahead for any help/suggestions!
The changes made in this NDK commit seem to explain the issue you're seeing. According to the commit description, __page_size was replaced with PAGE_SIZE for Android API levels 12 and under. As you're using API level 9 and code which directly references __page_size, you're seeing an effect from this change.
However, it looks like the method signature for int getpagesize() hasn't changed across NDK versions or across API levels, so you should be able to resolve this error by replacing the usage of __page_size with getpagesize() in the following locations:
SuperpoweredSource/decoder/SuperpoweredDecoder.cpp:120
SuperpoweredSource/decoder/hlsreader.cpp:582
Update:
To fix it without modifying the Superpowered source code, you'd need to define the symbol __page_size. To do that, you could build a tiny dummy library which just contains
#include <unistd.h>
extern unsigned int __page_size = getpagesize();
Then, add a module for this library to your Android.mk (or your build.gradle if you're using the new experimental system) and make the module for Superpowered depend on the dummy module.
Or, you could file a bug report with Superpowered.
So as a workaround for the situation I reverted NDK to r10e which worked. Will be using it until Superpowered library gets a fix. Great thanks to #bullsy