gpt4 book ai didi

linker - 使用 mingw 链接到 libav* 的 undefined reference

转载 作者:行者123 更新时间:2023-12-04 22:52:39 27 4
gpt4 key购买 nike

概述

我正在尝试从 ffmpeg 构建示例文件之一在 Windows 上使用 mingw 的 src 目录,但我得到了大量对 libav* 的 undefined reference 功能。

我已经看过 this question和其他几个,但没有一个能解决我的问题。具体来说,我没有构建 C++ 程序,也没有使用 g++ , 所以整个 extern "C"事情不适用(实际上我已经尝试过了,但没有奏效)。

详情

我已经下载了Zeranoe64-bit dev package , 并解压到 C:\apps\pf\ffmpeg .现在我只是在尝试构建 decoding_encoding.c文件在 doc/examples .我的 CWD 是 C:\apps\pf\ffmpeg\doc\examples ,我的命令看起来像这样(续行和添加注释):

#Compile
gcc -o decoding_encoding.obj -c -IC:\apps\pf\ffmpeg\include decoding_encoding.c

#Link
gcc -o decoding_encoding.exe decoding_encoding.obj \
-LC:\apps\pf\ffmpeg\lib -lavformat -lavcodec -lavdevice \
-lavfilter -lavutil -lswscale -lm

编译工作正常,但链接吐出这些错误:
decoding_encoding.obj:decoding_encoding.c:(.text+0xca): undefined reference to `av_get_channel_layout_nb_channels'
decoding_encoding.obj:decoding_encoding.c:(.text+0x131): undefined reference to `avcodec_find_encoder'
decoding_encoding.obj:decoding_encoding.c:(.text+0x179): undefined reference to `avcodec_alloc_context3'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1fa): undefined reference to `av_get_sample_fmt_name'
decoding_encoding.obj:decoding_encoding.c:(.text+0x26c): undefined reference to `av_get_channel_layout_nb_channels'
decoding_encoding.obj:decoding_encoding.c:(.text+0x28f): undefined reference to `avcodec_open2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x313): undefined reference to `avcodec_alloc_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x3c8): undefined reference to `av_samples_get_buffer_size'
decoding_encoding.obj:decoding_encoding.c:(.text+0x3d6): undefined reference to `av_malloc'
decoding_encoding.obj:decoding_encoding.c:(.text+0x44f): undefined reference to `avcodec_fill_audio_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x4ce): undefined reference to `av_init_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x5c2): undefined reference to `avcodec_encode_audio2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x63a): undefined reference to `av_free_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x680): undefined reference to `avcodec_encode_audio2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x6f8): undefined reference to `av_free_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x722): undefined reference to `av_freep'
decoding_encoding.obj:decoding_encoding.c:(.text+0x72d): undefined reference to `avcodec_free_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x738): undefined reference to `avcodec_close'
decoding_encoding.obj:decoding_encoding.c:(.text+0x743): undefined reference to `av_free'
decoding_encoding.obj:decoding_encoding.c:(.text+0x77b): undefined reference to `av_init_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x7a1): undefined reference to `avcodec_find_decoder'
decoding_encoding.obj:decoding_encoding.c:(.text+0x7e9): undefined reference to `avcodec_alloc_context3'
decoding_encoding.obj:decoding_encoding.c:(.text+0x840): undefined reference to `avcodec_open2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x8e6): undefined reference to `av_free'
decoding_encoding.obj:decoding_encoding.c:(.text+0x947): undefined reference to `avcodec_alloc_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x999): undefined reference to `avcodec_get_frame_defaults'
decoding_encoding.obj:decoding_encoding.c:(.text+0x9c2): undefined reference to `avcodec_decode_audio4'
decoding_encoding.obj:decoding_encoding.c:(.text+0xa44): undefined reference to `av_samples_get_buffer_size'
decoding_encoding.obj:decoding_encoding.c:(.text+0xb7d): undefined reference to `avcodec_close'
decoding_encoding.obj:decoding_encoding.c:(.text+0xb88): undefined reference to `av_free'
decoding_encoding.obj:decoding_encoding.c:(.text+0xb96): undefined reference to `avcodec_free_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0xbe4): undefined reference to `avcodec_find_encoder'
decoding_encoding.obj:decoding_encoding.c:(.text+0xc2c): undefined reference to `avcodec_alloc_context3'
decoding_encoding.obj:decoding_encoding.c:(.text+0xcee): undefined reference to `av_opt_set'
decoding_encoding.obj:decoding_encoding.c:(.text+0xd08): undefined reference to `avcodec_open2'
decoding_encoding.obj:decoding_encoding.c:(.text+0xd8c): undefined reference to `avcodec_alloc_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0xe2f): undefined reference to `av_image_alloc'
decoding_encoding.obj:decoding_encoding.c:(.text+0xe83): undefined reference to `av_init_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0xfd3): undefined reference to `avcodec_encode_video2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x105f): undefined reference to `av_free_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x10a9): undefined reference to `avcodec_encode_video2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1135): undefined reference to `av_free_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x117e): undefined reference to `avcodec_close'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1189): undefined reference to `av_free'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1194): undefined reference to `av_freep'
decoding_encoding.obj:decoding_encoding.c:(.text+0x119f): undefined reference to `avcodec_free_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1272): undefined reference to `avcodec_decode_video2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x13b1): undefined reference to `av_init_packet'
decoding_encoding.obj:decoding_encoding.c:(.text+0x13fa): undefined reference to `avcodec_find_decoder'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1442): undefined reference to `avcodec_alloc_context3'
decoding_encoding.obj:decoding_encoding.c:(.text+0x14ba): undefined reference to `avcodec_open2'
decoding_encoding.obj:decoding_encoding.c:(.text+0x153e): undefined reference to `avcodec_alloc_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x1674): undefined reference to `avcodec_close'
decoding_encoding.obj:decoding_encoding.c:(.text+0x167f): undefined reference to `av_free'
decoding_encoding.obj:decoding_encoding.c:(.text+0x168a): undefined reference to `avcodec_free_frame'
decoding_encoding.obj:decoding_encoding.c:(.text+0x16ab): undefined reference to `avcodec_register_all'
collect2.exe: error: ld returned 1 exit status

最佳答案

我已经可以在 README 中看到这个库是用 MinGW-w64 构建的,目标是 64 位。普通的旧 MinGW 不支持 64 位目标。因此,如果您使用 MinGW,那么它当然无法链接到 64 位库,因此您会遇到这些错误。

要解决您的问题,只需安装 MinGW-w64。我强烈建议从 下载它的发行版here .没有安装噩梦:只需解压,添加binPATH环境变量,你很高兴。

最后,看看这个 post ,了解谁是谁可能对您有用。

关于linker - 使用 mingw 链接到 libav* 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19428864/

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