编译时报错如下:
/usr/include/libavutil/common.h:168: 错误:'UINT64_C' was not declared in this scope
解决:
在common.h里面添加#ifndef UINT64_C#endif
2. 调试
#define LOG_TAG "TAG" //自定义的变量,相当于logcat函数中的tag
#undef LOG
#include
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
可以通过LOGD打印日志
比如 LOGD("strPwd=%s",strPwd);
3. 调用第三方库
NDK 编译和使用静态库、动态库
情况一:编译静态库
情况二:编译动态库
情况三:编译动态库+静态库
情况四:已有第三方静态库(动态库),编译静态库(动态库)
默认所有代码和文件在$project/jni下,否则特殊说明。
情况一:编译静态库
文件Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_STATIC_LIBRARY)
文件Application.mk:
APP_MODULES:=hello-jni
情况二:编译动态库
文件Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_SHARED_LIBRARY)
情况三:编译动态库+静态库
文件Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib_static
LOCAL_SRC_FILES := src.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib_shared
LOCAL_SRC_FILES := src2.c
LOCAL_STATIC_LIBRARIES:= mylib_static
include $(BUILD_SHARED_LIBRARY)
情况四:已有第三方静态库(动态库),编译静态库(动态库)
文件Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := thirdlib1 # name it whatever
LOCAL_SRC_FILES :=$(TARGET_ARCH_ABI)/libthird1.a # or $(so_path)/libthird1.so
#LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY) #or PREBUILT_SHARED_LIBRARY
include $(CLEAR_VARS)
LOCAL_MODULE := mylib_use_thirdlib
LOCAL_SRC_FILES := src.c
LOCAL_STATIC_LIBRARIES:= thirdlib1 #or LOCAL_SHARED_LIBRARY
include $(BUILD_SHARED_LIBRARY) #如果编译静态库,需要Application.mk
补充:
include $(CLEAR_VARS)ref :
http://blog.csdn.net/yanzi1225627/article/details/7544789
http://jefry.iteye.com/blog/1261431
http://hi.baidu.com/joec3/item/0e4fca153eb0e3dcbf904211