The source code of the project is as follows:
Http://code.google.com/p/flying-on-android/
Because dlopen and other functions are used, you must add libdl to local_shared_libraries when compiling toollibrary.
When you call Android. mk in the subdirectory of the current directory, the statement is as follows:
Include $ (local_path)/lib/Android. mk
If it is written as follows:
Include lib/Android. mk
The actual search directory is/lib/Android. mk.
Dlsym uses the name to locate the method. Therefore, the method cannot be overloaded.
Dlopen can also be used to input paths, such as/system/lib/libflying_display.so.
The compiled. So library is installed in the/system/lib directory:
Local_module_path: = $ (target_out_shared_libraries)
If you want to install it under/system/lib/HW, write as follows:
Local_module_path: = $ (target_out_shared_libraries)/HW
What is the relationship between local_shared_libraries and local_ldlibs?
For the former, it is necessary to check whether the dynamic library needs to be re-compiled during compilation, and the latter does not.
If libskia. So is used in the source code, write as follows:
Local_shared_libraries = libskia
To use ndk, write as follows:
Local_ldlibs =-lskia
In the source code, local_ldlibs applies to host shared libs (you do not need to check whether the source file of the dynamic library is changed), while local_shared_libraries applies to target shared libs (requires detection)
When compiling the toollibrary in flying in the source code, you need to link the libdl. So library. There are two writing methods:
Local_shared_libraries: = libdl
Local_ldlibs + =-LDL
The first one can be compiled, and the second one fails to be compiled. dlopen and other definitions cannot be found.
Because libdl. So also belongs to target shared libs. Its source code is located in the/bionic/libdl/directory.
For host library and target library, refer to the following:
The host library and target Library
Http://osr507doc.sco.com/en/tools/ShLib_Implement_Host.Target.html
For more information about local_prelink_module, see:
Android compilation system-continued
Http://blog.csdn.net/a345017062/archive/2011/05/24/6442325.aspx
For dlopen dlsym dlclose and other functions, refer to here:
Dlopen dlsym dlclose Parsing
Http://blog.csdn.net/yujixi123/archive/2010/07/28/5772117.aspx
Note that if the source code is a. cpp file, you must add
Extern "C "{
}
Otherwise, the dlopen is successful, but the symbol cannot be found with dlsym.
The system may use the G ++ compiler to compile the. cpp file. The compiled symbol name is not in the C style, so it cannot be found.
You can refer to here:
GCC and G ++ Testing
Http://blog.csdn.net/a345017062/archive/2011/05/31/6457761.aspx
Write a macro definition at the beginning of the toollibrary. cpp file:
# Define log_tag "toollibrary"
Logw ("ABC"); is used in the toollibrary. cpp file to print the logs:
W/tooldisplay (2176): Hello toollibrary!
Do not worry about warnings during compilation:
Warning: this is the location of the previous definition