I have created an android project on windows with ndk template. I want to include ndk-build project into android studio. This ndk-build project is working fine separately when I run ndk-build command.
My requirement is to convert and use it in android studio so that I can debug the code on android mobile. At this time I am just using share library (so file) and call the required function from adb shell.
I have copied all the source files of my separate ndk project into my android studio project and also added them into native-lib(created by default by android studio) library. But, I am getting an exception on including glib.h.
I am not sure actually how to resolve it.
Please suggest something.
Read this:https://developer.gimp.org/api/2.0/glib/glib-compiling.html
I usually use the following:[To complie]
gcc `pkg-config --cflags --libs glib-2.0 dbus-glib-1` progname.c
Hope this will help you.
Related
I have just formatted my computer and reinstalled android studio and sdk & ndk. I've created a new project but now I can't build it with c++ source because I keep getting this error:
.../x86_64-linux-android/bin\ld: error: cannot find -l1
I am not event linking a library called "1". What is it for?
Seems like latest ndk or android-studio has some sort of naming problem or I had a problem when installing it.
I was linking the android library
find_library(ANDROID android)
target_link_library(... ${ANDROID})
but it seems like ${ANDROID} was set to 1. I set it to "android" by hand and now it compiles as expected.
One of the first things the CMake toolchain file does is set(ANDROID TRUE) to indicate that the build is targeting Android. You can't use ANDROID as a variable name in your CMakeLists.txt because it's already used. Best to assume that anything prefixed with ANDROID is part of the implementation.
We are trying to build capicxx-core-runtime for an ARM based platform running Android Pie. It's an open source IPC framework which is part of the GENIVI initiative by major automotive OEM's. Our AIM is to bring the IPC framework into our Android system.
The git repo is placed here https://github.com/GENIVI/capicxx-core-runtime.git
I am using the Android NDK version r17b and building using the following command to configure the cmake based build.
cmake -DCMAKE_TOOLCHAIN_FILE=/home/hp/downloads/android-ndk-r17b/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=27 ../
When I compile using 'make', I see the individual cpp files are compiled, but I am getting following errors during linking as shown in the link below.What is the configuration that I may be missing.
Linker error log
the capicxx-core-runtime is building a shared library, so you need to resolve all of it's internal symbols, including the c++ runtime.
To quickly test this: edit the capicxx-core-runtime CMakeLists.txt to link the c++_shared runtime, line 130:
target_link_libraries(CommonAPI PRIVATE ${DL_LIBRARY} ${DLT_LIBRARIES})
becomes
target_link_libraries(CommonAPI PRIVATE ${DL_LIBRARY} ${DLT_LIBRARIES} c++_shared)
and rerun your cmake command and make command.
It seems that capicxx-core-runtime can be buildable now for Android (both NDK and AOSP) out the box, please see corresponding pull requests: https://github.com/GENIVI/capicxx-core-runtime/pulls?q=author%3Ankh-lab+
Also here is simple example for AndroidStudio how it could be used with vSOME/IP transport: https://github.com/nkh-lab/ndk-capi-hello-world
I have an Android app that uses OpenCV's Java wrapper for image processing. To add OpenCV to the project, I had to add the following line to gradle.properties:
android.useDeprecatedNdk=true
This had been working fine without any warnings or errors (that I know of) up until I updated my Android Studio and Gradle after a long time (I'm using Gradle 2.2.2 and Android Studio 2.2.2 now). Now when I build my app, I get the following warnings on the messages window:
Warning:Native C/C++ source code is found, but it seems that NDK
option is not configured. Note that if you have an Android.mk, it is
not used for compilation. The recommended workaround is to remove the
default jni source code directory by adding:
Warning:Deprecated NDK integration enabled by useDeprecatedNdk flag in
gradle.properties will be removed from Android Gradle plugin soon.
Even though the build is successful at this time, as the second warning informs, this is highly likely to cause some trouble in the future, so I want to resolve them as soon as possible before things go sideways.
Does anyone know how to get resolve these warnings? Or are there any other way to import OpenCV to an Android project, other than adding all the compiled code (the .so files) and setting the flag I mentioned earlier? Any help on this will be appreciated.
I would suggest to migrate over to using the native support with cmake. You could check the link which provides a step-by-step tutorial to add OpenCV using cmake via the following link.
You're code should stay the same without any changes, only necessary action is to figure out how to include them within the build process using CMakeLists.txt.
In the project pane, right click your app (in my React Native project it's the "app" catalog), and select "Link C++ project with gradle".
Now you must find the Android.mk file - it should be already generated in your_app/app/build/intermediates/ndk/debug/
I'm cross-compiling library for android using qt-opensource-windows-x86-android-5.4.0.
But I can't more compile.. I don't know why..
Below is error messages.
09:25:16: Internal Error: Could not find .pro file.
Error while building/deploying project cmirisLib (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.0))
When executing step "Build Android APK"
This is not application. I want to get a 'lib[libraryname].so' for android.
Could you help me?
Regards,
UK
In my case, this problem was caused because I was porting a program to Android from Desktop environment. In Android your launcher is not an executable file but a lib. However, you must ensure that you get an entry point and for that QMake seems to somehow require that at least some project in the build tree has
TARGET = app
in order to build/deploy correctly in Android. So, I had to add something like this to the .pro file
TEMPLATE = lib # for the Desktop (Lin/Win/Mac) this is a "lib"
android {
TEMPLATE = app # for Android this is an "app"
}
I addition, I guess it is worth reminding that you might need to provide a main() function (which you could had left outside the code).
Hope it helps
According to this :
https://bugreports.qt.io/browse/QTCREATORBUG-13566
Disable the "Make Install" and "Build Android APK" Steps from within the kit settings.
Im trying to carry out static source code analysis for my android native project written in C/C++ using scan-build.
I tried the instructoins on this page(http://clang.llvm.org/get_started.html#build) for building and running scan-build. All these are done in Ubuntu 10.10, 64bit version.
Since I'm building my project in android source, the compilers used are gcc and g++ located in android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/.
It is said that I can configure scan-build to work with gcc/g++ using --use-c++ and --use-cc options.
But when I run the command: (./run_scanbuild.sh is the build script)
scan-build --use-cc=/home/chulwoo/8655_GB_AU_2_30/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc --use-c++=/home/chulwoo/8655_GB_AU_2_30/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-g++ ./run_scanbuild.sh
it says :
scan-build: 'clang' executable not found in '/home/chulwoo/Clang/llvm/tools/clang/tools/scan-build/bin'.
scan-build: Using 'clang' from path: /home/chulwoo/Clang/build/Debug+Asserts/bin//clang
Seems the --use-c++ and --use-cc options are simply ignored.
Does any one know how to make scan-build work with android prebuilt gcc/g++ ?
Or, is it feasible to build my project using Clang in android?
Thanks in advance.
Jin.
Okay ,this was a stupid question.
Just build it with following command, and it surely will generate static-analysis result.
Here lets assume that gcc is used for building.
scan-build gcc ...whatever you wanna give as options...
The scan-build is really a nice tool, hope you guys enjoy it.