1. 程式人生 > >undefined reference to `av_register_all' 問題解決

undefined reference to `av_register_all' 問題解決

之前一直在eclipse上使用ndk

前一陣轉到Android studio上 使用ndk 被這個undefined reference to `av_register_all'  問題困擾了很久,一度認為是路徑沒有配置好

後來發現解決方法

#include <libavcodec/avcodec.h>

#include <libavformat/avformat.h>

引入標頭檔案因為實在cpp的環境下引入的需要

extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

}

切記  exterm後面一定要跟{}

我之前是這樣寫的

extern "C"

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
是沒有用的 這種是錯誤的一定要帶{}否則還是回報同樣的錯誤