ffmpeg中的未定义引用(使用代码块)

时间:2015-02-06 03:46:42

标签: c++ ffmpeg codeblocks

我目前正在使用ffmepg代码块测试视频编码程序。我遇到了几个未定义的引用警告。我已经在互联网上检查并在标题中添加了外部“c”,但它仍然无法正常工作。请帮我查一下。

以下是代码的一部分:

extern "C" {

#include "libavcodec/avcodec.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/mathematics.h"
#include "libavutil/samplefmt.h"


}

#include <math.h>
#include "libavutil/opt.h"

static void video_encode_example(const char *filename, int codec_id)
{

AVCodec *codec;
AVCodecContext *c= NULL;
int i, ret, x, y, got_output;
FILE *f;
AVFrame *frame;
AVPacket pkt;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
printf("Encode video file %s\n", filename);
/* find the mpeg1 video encoder */
codec = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}

int main(int argc, char **argv)
{
avcodec_register_all();
video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);

return 0;
}

给出的错误:

|| === Build:在ffmepg_video_en中调试(编译器:GNU GCC编译器)=== | obj / Debug / main.o ||函数video_encode_example':| codeblocksfile/ffmepg_video_en/main.cpp|36|undefined reference to avcodec_find_encoder'| codeblocksfile / ffmepg_video_en / main.cpp | 41 |对avcodec_alloc_context3'| codeblocksfile/ffmepg_video_en/main.cpp|63|undefined reference to未定义的引用av_opt_set(void *,char const *,char const *,int)'| codeblocksfile / ffmepg_video_en / main.cpp | 65 |未定义引用avcodec_open2'| codeblocksfile/ffmepg_video_en/main.cpp|74|undefined reference to av_frame_alloc'| codeblocksfile / ffmepg_video_en / main.cpp | 85 |未定义引用av_image_alloc(unsigned char**, int*, int, int, AVPixelFormat, int)'| codeblocksfile/ffmepg_video_en/main.cpp|92|undefined reference to av_init_packet'| codeblocksfile / ffmepg_video_en / main.cpp | 112 |未定义引用avcodec_encode_video2'| codeblocksfile/ffmepg_video_en/main.cpp|120|undefined reference to av_free_packet'| codeblocksfile / ffmepg_video_en / main.cpp | 126 |未定义引用avcodec_encode_video2'| /home/yonghao/codeblocksfile/ffmepg_video_en/main.cpp|134|undefined reference to av_free_packet'| codeblocksfile / ffmepg_video_en / main.cpp | 140 |未定义引用avcodec_close'| codeblocksfile/ffmepg_video_en/main.cpp|141|undefined reference to av_free'| codeblocksfile / ffmepg_video_en / main.cpp | 142 |未定义引用av_freep'| codeblocksfile/ffmepg_video_en/main.cpp|143|undefined reference to av_frame_free'| obj / Debug / main.o ||函数main':| codeblocksfile/ffmepg_video_en/main.cpp|151|undefined reference to avcodec_register_all'| || ===构建失败:16个错误,0个警告(0分钟,1秒(秒))=== |

0 个答案:

没有答案