StudyCpp new packet, then the introduction of all files in the package studyCpp CMakeLists.txt as follows:
file(GLOB sourceFiles studyCpp/*.h studyCpp/*.cpp studyCpp/*.c)
#file(GLOB sourceFiles logCpp/*.h logCpp/*.cpp logCpp/*.c)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp
${sourceFiles}
)
Creating mylog.h for printing logs, as follows:
// 使用NDK里面的日志库来打印 liblog.so
#include <android/log.h>
#define TAG "Hongx"
#define LOGD(...)__android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
Creating main.h and main.cpp as follows:
LOGD("CCCCCCCCCCCCCCCCCCCCCCCCCCCCC");
Call mian () function in the native-lib.cpp as follows:
Run to view the results: