The previous blog post mentions the use of ARM-NONE-LINUX-GNUEABI-GCC to cross-compile the porting program onto the Android platform. Also mentioned that there is no glibc in Android, so the ARM-NONE-LINUX-GNUEABI-GCC compiled program needs to specify the connector at compile time and copy the required dynamic library to the Android machine.
See: http://thedevilking.blog.51cto.com/8144260/1364547
so in order to be more convenient to use the cross-compiler to transplant our needs of the program or library to the Android platform, we generally use the NDK compilation (NDK download configuration See Google official Note:/http developer.android.com/tools/sdk/ndk/index.html)
In the process of porting, sometimes we need to use the cross-compiler tool alone (such as the makefile of a program's dependent library is generated using configure, then we need to use the./configure cc=arm-linux-androideabi- To generate the makefile we need)
Therefore, the NDK can be used to generate the cross-compilation tools we need :
Run in the NDK directory:
./build/tools/make-standalone-toolchain.sh--platform=android-15auto-config:--toolchain= Arm-linux-androideabi-4.6copying prebuilt binaries ... Copying sysroot Headers and libraries ... Copying libstdc++ Headers and libraries ... Creating package file:/tmp/ndk-wwtao/arm-linux-androideabi-4.6.tar.bz2cleaning ... Done.
--platform=android-15 is used to set the Android API version, the rest of the options can be viewed through--help.
This gives the NDK generated cross-compilation toolchain.
After we have ported some of the required libraries using the cross-compilation tool, we can migrate to the Android platform. In general, the migration process is similar, modify the makefile cross compiler, add the location of the search header file, and the location of the link library. If you encounter an error that the header file cannot find, the common possibility is that the header file in the cross-compiler include is not the same as the path, which is generally solved by Google.
For compiling a program based on some dependent libraries, which are already sometimes the easiest way to find it in an Android system is to locate its header file (which is not in the Include header file cross-box), then copy the corresponding. So file from the Android system and compile it with a cross-compiler or ndk-build.
arm-linux-androideabi-gcc-i[header file directory]-l[dynamic library location] Filename.c-o filename
or write android.mk files, using Ndk-build.
Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = client_androidlocal_src_files: = Client.clocal_cflags + =-i/home/wwtao/desktop/bluetooth/include/includelocal_ldlibs + =-l/home/wwtao/desktop/bluetooth/libfrompanda- Lbluetoothinclude $ (build_executable) #include $ (build_static_library) #include $ (build_shared_library)
whereLocal_path: = $ (call My-dir) set Local_path as the current path
Include $ (clear_vars) is to empty the current variable
Local_module is the file name generated after compilation
Local_src_files is the compiled source file
Local_cflags is to set the header file search path at compile time
Local_ldlibs is the path to set the search dynamic link library at compile time
The include $ (build_executable) is the build executable, if Build_static_library is a static library, if it is build_shared_library.
This article from "thedevilking" blog, declined reprint!
Build the cross compiler for Android, and use the NDK to compile the porting