Levmar ndk compilation, levmarndk

Source: Internet
Author: User

Levmar ndk compilation, levmarndk
Levmar is a powerful and efficient C/C ++ library. It uses the Levenberg-marquard (LM) optimization algorithm to solve the non-linear least square problem. Official Website: http://users.ics.forth.gr /~ Lourakis/levmar/cited on PC, there are a lot of information available on the Internet, but I want to apply it to Android, google a bit, cannot find too much information, only a foreign project a few years ago: https://github.com/3deggi/levmar-ndk because the project is too long, or use eclipse IDE to develop, I tried to move to Android Studio to compile, or compilation is not successful, in the end, you only need to reconfigure the eclipse environment. The most important thing is to use an earlier version of NDK for compilation. The NDK version I chose is 12b. Some minor errors occurred during the process, so I made a slight adjustment and compiled it according to the eclipse NDK step. There is a configuration in application. mk in the project: APP_ABI: = armeab, which is the CPU instruction set configuration. Generally, we will be compatible with multiple CPUs during compilation, so we will change it to: APP_ABI: = all in compilation. There is no major problem. Some warnings are provided and compilation is successful. After compilation is successful, the arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64 Instruction Set Directory appears under the libs directory. So I tested it on a real machine. Some mobile phones passed and some failed to run. After debugging, I found that the CPU supports different instruction sets for different mobile phones, so I output the instruction sets for each mobile phone using the following code:

 String[] abis = new String[]{}; abis = Build.SUPPORTED_ABIS; 
The results are as follows: meizu note2: vivo Y51A oppo r9s: arm64-v8a, armeabi-v7a, armeabi, vivo Y51A can run through, while the other two phones run will crash. Then I guess it could be that the arm64-v8a library went wrong. So I deleted the file and the file in it. As a result, all the mobile phones passed. From this we will probably know that when the APP obtains a dynamic library, it first obtains the dynamic library in the first directory based on the instruction set supported by the CPU. If it cannot, it will be obtained from the directory of the supported instruction set, and so on. Of course this project is compiled successfully, because the CPU of most mobile phones currently supports armeabi-v7a and armeabi. But we also know that many third-party libraries will be compatible with the arm64-v8a instruction set, which should be faster. I also tried to recompile the levmar library to make it compatible with the arm64-v8a instruction set. I downloaded the NDK of another version to try it, because the ndk-build command uses Clang by default in r13, And they will remove GCC in later versions. Levmar actually used some libraries in other languages such as matlab. I am worried that compilation errors may occur. After I use the NDK of another version for compilation, the compilation is successful, but this error will be reported during JNI call: 06-22 16:32:40. 741: A/libc (5024): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 5024 (hvrl. levmar). The cause of this error is that the corresponding JNI implementation method cannot be found, or the native code execution fails. Because I cannot get the error log for C/C ++, I can only temporarily discard the compatible arm64-v8a instruction set. The levmar library is compiled successfully. It is a static levmar. a library. levmar also uses clapack and is also compiled into the. a static library. Link to the project that I have compiled: https://pan.baidu.com/s/1plpv4ovwelcome everyone else, or discuss it together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.