gpt4 book ai didi

linker - FFMPEG 链接错误

转载 作者:行者123 更新时间:2023-12-01 10:46:09 25 4
gpt4 key购买 nike

我正在尝试编译 transcoding example from the FFMPEG site 的修改版本,我已经使用了所有必需的包含并使用它加入了库:

INCLUDEPATH += $$(FFMPEG_DEV_PATH)\include
LIBS += -L$$(FFMPEG_DEV_PATH)\lib -lavformat -lavcodec -lavutil -lswscale -liconv -lz -lavfilter

但我收到了这个我无法理解的链接错误:

  "avio_close(AVIOContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_strerror(int, char*, unsigned long)", referenced from:
av_make_error_string(char*, unsigned long, int) in PhVideoEncoder.o
"av_rescale_q(long long, AVRational, AVRational)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_frame_free(AVFrame**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_read_frame(AVFormatContext*, AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_close(AVCodecContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_dump_format(AVFormatContext*, int, char const*, int)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_frame_alloc()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"av_free_packet(AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_init_packet(AVPacket*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_opt_set_bin(void*, char const*, unsigned char const*, int, int)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_register_all()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_rescale_q_rnd(long long, AVRational, AVRational, AVRounding)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_write_trailer(AVFormatContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avfilter_graph_free(AVFilterGraph**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avfilter_inout_free(AVFilterInOut**)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_new_stream(AVFormatContext*, AVCodec const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"avcodec_copy_context(AVCodecContext*, AVCodecContext const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avcodec_find_decoder(AVCodecID)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"avcodec_find_encoder(AVCodecID)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avfilter_get_by_name(char const*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_graph_alloc()", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_inout_alloc()", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_close_input(AVFormatContext**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, AVPacket const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_decode_video2(AVCodecContext*, AVFrame*, int*, AVPacket const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_encode_audio2(AVCodecContext*, AVPacket*, AVFrame const*, int*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"avcodec_encode_video2(AVCodecContext*, AVPacket*, AVFrame const*, int*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"avfilter_graph_config(AVFilterGraph*, void*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_register_all()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avformat_free_context(AVFormatContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avformat_write_header(AVFormatContext*, AVDictionary**)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_get_sample_fmt_name(AVSampleFormat)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_buffersink_get_frame(AVFilterContext*, AVFrame*)", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"avfilter_graph_parse_ptr(AVFilterGraph*, char const*, AVFilterInOut**, AVFilterInOut**, void*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_find_stream_info(AVFormatContext*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"av_interleaved_write_frame(AVFormatContext*, AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_buffersrc_add_frame_flags(AVFilterContext*, AVFrame*, int)", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"avfilter_graph_create_filter(AVFilterContext**, AVFilter const*, char const*, char const*, void*, AVFilterGraph*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_get_default_channel_layout(int)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_alloc_output_context2(AVFormatContext**, AVOutputFormat*, char const*, char const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_get_channel_layout_nb_channels(unsigned long long)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_frame_get_best_effort_timestamp(AVFrame const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_log(void*, int, char const*, ...)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
PhVideoEncoder::flush_encoder(unsigned int) in PhVideoEncoder.o
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
...
"av_free(void*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_malloc(unsigned long)", referenced from:
av_malloc_array(unsigned long, unsigned long) in PhVideoEncoder.o
"av_strdup(char const*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avio_open(AVIOContext**, char const*, int)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o

我尝试寻找丢失的库,但没有运气......我错过了什么?

编辑

感谢第一个答案,我添加了 extern C 东西,但我仍然面临一些错误:

Undefined symbols for architecture x86_64:
"_av_buffersink_get_frame", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"_av_buffersrc_add_frame_flags", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"_avfilter_get_by_name", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_alloc", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_config", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_create_filter", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_free", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"_avfilter_graph_parse_ptr", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_inout_alloc", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_inout_free", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_register_all", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
ld: symbol(s) not found for architecture x86_64

最佳答案

this post - 很可能在将 C++ 代码与 FFMPEG 的 C 接口(interface)混合时,您忘记了 extern "C" 关键字,因此链接器正在使用 C++ 函数名称修饰,因此无法找到引用。您应该像这样用 extern "C" 包装 FFMPEG 包含:

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

关于linker - FFMPEG 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25742626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com