NDK中把源文件都添加到makefile中了结果编译时报以下错误
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:504: error: undefined reference to 'h264_record::write_audio_data(short*, int, int)'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:475: error: undefined reference to 'h264_record::wirte_video_data(unsigned char*, int, unsigned int)'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:438: error: undefined reference to 'h264_record::h264_record()'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:443: error: undefined reference to 'h264_record::init(char const*)'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:451: error: undefined reference to 'h264_record::uninit()'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:452: error: undefined reference to 'h264_record::~h264_record()'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:438: error: undefined reference to 'h264_record::h264_record()'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:443: error: undefined reference to 'h264_record::init(char const*)'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:451: error: undefined reference to 'h264_record::uninit()'
/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/jni/../jni/../ECMedia/source/RecordLocal.cpp:452: error: undefined reference to 'h264_record::~h264_record()'
collect2: error: ld returned 1 exit status
make: *** [/Users/gezhaoyou/workspace/projects/yuntongxun/MyWebRtc_2.x/obj/local/armeabi/libECMedia.so] Error 1
反复排查,makefile文件添加的正确,路径什么的都没有错,奇怪了。
最终找到原因:android.mk 中指定了CPP的拓展名,原来是这样的:
LOCAL_CPP_EXTENSION := .cc
, 我新建的文件是以.cpp
结尾的,把这句去掉,或者改成LOCAL_CPP_EXTENSION := .cc .cpp
问题解决!
网友评论