报错信息:
../../../../src/main/cpp/native-lib.cpp:9: error: undefined reference to 'avcodec_configuration()'
我的 native-lib.cpp 为:
#include <jni.h>
#include <string>
#include "libavcodec/avcodec.h"
extern "C" JNIEXPORT jstring JNICALL
Java_com_example_vtion_ffmpegwufour_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = avcodec_configuration();
return env->NewStringUTF(hello.c_str());
}
应添加 :
extern "C" {
}
添加完毕的代码为:
#include <jni.h>
#include <string>
extern "C" {
#include "libavcodec/avcodec.h"
extern "C" JNIEXPORT jstring JNICALL
Java_com_example_vtion_ffmpegwufour_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = avcodec_configuration();
return env->NewStringUTF(hello.c_str());
}
}