Android studio 2.2. X above uses cmake compilation to call the underlying C to generate dependency libraries

Recently, the latest NDK compilation method cmake of Android studio has been used to compile the underlying cpp file. Since cmake syntax has not been touched before, the Official Learning document address is attached first: https://developer.android.com/ndk/guides/cmake.html , and friendship Chinese translation website: https://www.zybuluo.com/khan-lau/note/254724 ;

There are a lot of underlying C files, as shown in the figure below

Question 1:

Native-lib.cpp provides an external interface, so the dependencies on other files are written in this file. Do you want to compile directly next? No, then you will get a compilation error. You can't find the functions in other C files in native-lib.cpp. Therefore, the C files are not compiled when cmake is compiled, so you need to add files in cmakelists.txt.

The contents of the cmakelists.txt file before modification are as follows:

Learn the official documentation of cmake. You can know the add_ Library () is the place to set the package generation. There is only one file, native-lib.cpp. In theory, it should include other files. Would you like to add other files? Yes, but so many files are too long. Of course, cmake must have expected this problem, so we can get a new skill and use aux_ source_ Directory(), add a file list at the source file location instead of a single file. The file content after get modification is as follows:

In this way, you need to synchronize after the sub changes, so that you can recompile.

Question 2:

Invalid Sign

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>