c++ - 在 Visual Studio 2008 中链接 libav 库

标签 c++ visual-studio-2008 static-linking

以静态方式记录OpenGL输出的动画

我按照以下步骤链接了 avlib 库。

  1. 我已经下载了 libav-win32-20130921.7z 文件 http://win32.libav.org/win32/并将所有文件解压到 文件夹 (d:/VC Projects/libav/)。 lib 子文件夹包含所有 .a 文件(libavcodec.a、libavdevice.a、libavfilter.a、libavformat.a、 libavresample.a、libavutil.a、libswscale.a 和 libavcodec.dll.a, libavdevice.dll.a, libavfilter.dll.a, libavformat.dll.a, libavresample.dll.a、libavutil.dll.a、libswscale.dll.a) 另外 到 7 个 .def 文件。

  2. 在我的主头文件中,我插入了以下代码:

extern "C" 
{
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavfilter/avfilter.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include <libavresample/avresample.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>

#pragma comment(lib, "D:/VC Projects/libav/lib/libavutil.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libswscale.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavfilter.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavresample.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavcodec.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavdevice.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavformat.a")
}
  1. 在项目设置中提供了额外的包含目录 "D:\VC Projects\libav\include"

当我编译项目时,出现 316 条错误和 31 条警告:

> libavcodec.a(pthread.o) : warning LNK4217: locally defined symbol
> __beginthreadex imported in function _ff_thread_init libavutil.a(avstring.o) : warning LNK4049: locally defined symbol
> __vsnprintf imported libavformat.a(aviobuf.o) : warning LNK4217: locally defined symbol __vsnprintf imported in function _avio_printf
> libavformat.a(rtpproto.o) : warning LNK4049: locally defined symbol
> __vsnprintf imported libavformat.a(url.o) : warning LNK4049: locally defined symbol __vsnprintf imported libavutil.a(log.o) : warning
> LNK4049: locally defined symbol __vsnprintf imported
> libavformat.a(mov.o) : warning LNK4217: locally defined symbol
> __gmtime64 imported in function _mov_read_mdhd libavformat.a(mxfenc.o) : warning LNK4217: locally defined symbol __gmtime64 imported in
> function _mxf_write_header libavformat.a(wtv.o) : warning LNK4217:
> locally defined symbol __gmtime64 imported in function
> _parse_media_type libavutil.a(parseutils.o) : warning LNK4049: locally defined symbol __gmtime64 imported libavformat.a(os_support.o) :
> warning LNK4049: locally defined symbol __errno imported
> libavutil.a(file_open.o) : warning LNK4049: locally defined symbol
> __errno imported libavformat.a(rtsp.o) : warning LNK4217: locally defined symbol __errno imported in function
> _udp_read_packet.constprop.5 libavformat.a(file.o) : warning LNK4049: locally defined symbol __errno imported libavformat.a(md5proto.o) :
> warning LNK4049: locally defined symbol __errno imported
> libavformat.a(network.o) : warning LNK4049: locally defined symbol
> __errno imported libavformat.a(file.o) : warning LNK4217: locally defined symbol __stat64 imported in function _file_check
> libavformat.a(md5proto.o) : warning LNK4217: locally defined symbol
> __iob imported in function _md5_close libavutil.a(log.o) : warning LNK4217: locally defined symbol __iob imported in function
> _av_log_default_callback libavutil.a(parseutils.o) : warning LNK4217: locally defined symbol __time64 imported in function _av_parse_time
> libavutil.a(parseutils.o) : warning LNK4217: locally defined symbol
> __mktime64 imported in function _av_parse_time libavutil.a(parseutils.o) : warning LNK4217: locally defined symbol
> __localtime64 imported in function _av_parse_time libavutil.a(file_open.o) : warning LNK4217: locally defined symbol
> __wsopen imported in function _avpriv_open libavutil.a(file_open.o) : warning LNK4217: locally defined symbol __sopen imported in function
> _avpriv_open libavformat.a(riffenc.o) : error LNK2001: unresolved external symbol ___divdi3 libavutil.a(mathematics.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavutil.a(rational.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(xa.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(xwma.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(yop.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(cutils.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavformat.a(rmdec.o) : error LNK2019:
> unresolved external symbol ___divdi3 referenced in function
> _rm_read_header libavformat.a(rtpenc.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(rtspdec.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(wtv.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(nutenc.o)
> : error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(nutdec.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(pcmdec.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(rawvideodec.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(mpegtsenc.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(mpegts.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(mxfdec.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(nsvdec.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavformat.a(mmf.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(mov.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(mpc8.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(mpegenc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(filmstripdec.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(flvenc.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(gsmdec.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(iss.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(dvenc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(dv.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(dxa.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavformat.a(ffmdec.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(avienc.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(avidec.o)
> : error LNK2001: unresolved external symbol ___divdi3
> libavformat.a(swfenc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavformat.a(cafdec.o) : error LNK2001: unresolved external symbol ___divdi3 libavformat.a(adxdec.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavformat.a(aiffenc.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(asfenc.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavformat.a(asfdec.o)
> : error LNK2001: unresolved external symbol ___divdi3
> libavcodec.a(error_resilience.o) : error LNK2001: unresolved external
> symbol ___divdi3 libavcodec.a(iirfilter.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavformat.a(mux.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavformat.a(utils.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavcodec.a(wmaenc.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavcodec.a(xsubenc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavcodec.a(libvpxenc.o) : error LNK2001: unresolved external symbol ___divdi3 libavcodec.a(ituh263enc.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavcodec.a(mpeg4videodec.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavcodec.a(ac3enc_fixed.o) : error LNK2001: unresolved external
> symbol ___divdi3 libavcodec.a(mpegaudiodec.o) : error LNK2001:
> unresolved external symbol ___divdi3
> libavcodec.a(mpegaudiodec_float.o) : error LNK2001: unresolved
> external symbol ___divdi3 libavcodec.a(h261enc.o) : error LNK2001:
> unresolved external symbol ___divdi3 libavcodec.a(mpegvideo_enc.o) :
> error LNK2001: unresolved external symbol ___divdi3
> libavcodec.a(mpeg12enc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavcodec.a(mpeg4videoenc.o) : error LNK2001: unresolved external symbol ___divdi3 libswscale.a(utils.o) : error LNK2001:
> unresolved external symbol ___divdi3 libswscale.a(yuv2rgb.o) : error
> LNK2001: unresolved external symbol ___divdi3 libavcodec.a(ffv1enc.o)
> : error LNK2001: unresolved external symbol ___divdi3
> libavcodec.a(flvenc.o) : error LNK2001: unresolved external symbol
> ___divdi3 libavutil.a(avstring.o) : error LNK2001: unresolved external symbol _snprintf libavutil.a(error.o) : error LNK2001: unresolved
> external symbol _snprintf libavutil.a(log.o) : error LNK2001:
> unresolved external symbol _snprintf libavutil.a(opt.o) : error
> LNK2001: unresolved external symbol _snprintf
> libavutil.a(channel_layout.o) : error LNK2001: unresolved external
> symbol _snprintf libavutil.a(samplefmt.o) : error LNK2001: unresolved
> external symbol _snprintf libavformat.a(id3v2.o) : error LNK2001:
> unresolved external symbol _snprintf libavformat.a(id3v1.o) : error
> LNK2001: unresolved external symbol _snprintf
> libavformat.a(httpauth.o) : error LNK2001: unresolved external symbol
> _snprintf libavutil.a(pixdesc.o) : error LNK2001: unresolved external symbol _snprintf libavformat.a(md5proto.o) : error LNK2001: unresolved
> external symbol _snprintf libavformat.a(rtpproto.o) : error LNK2001:
> unresolved external symbol _snprintf libavformat.a(tcp.o) : error
> LNK2001: unresolved external symbol _snprintf libavformat.a(udp.o) :
> error LNK2001: unresolved external symbol _snprintf
> libavformat.a(gopher.o) : error LNK2001: unresolved external symbol
> _snprintf libavformat.a(http.o) : error LNK2001: unresolved external symbol _snprintf libavformat.a(mmsh.o) : error LNK2001: unresolved
> external symbol _snprintf libavformat.a(mmst.o) : error LNK2001:
> unresolved external symbol _snprintf libavformat.a(vqf.o) : error
> LNK2001: unresolved external symbol _snprintf libavformat.a(wavdec.o)
> : error LNK2001: unresolved external symbol _snprintf
> libavformat.a(wtv.o) : error LNK2001: unresolved external symbol
> _snprintf libavformat.a(yuv4mpeg.o) : error LNK2001: unresolved external symbol _snprintf libavformat.a(mpjpeg.o) : error LNK2001:
> unresolved external symbol _snprintf libavformat.a(rtsp.o) : error
> LNK2019: unresolved external symbol _snprintf referenced in function
> _ff_rtsp_connect libavformat.a(rtspdec.o) : error LNK2001: unresolved external symbol _snprintf libavformat.a(smoothstreamingenc.o) : error
> LNK2001: unresolved external symbol _snprintf libavformat.a(movenc.o)

..........

error LNK2001: unresolved external symbol _snprintf libavcodec.a(ass.o) : error LNK2001: unresolved external symbol _snprintf libavformat.a(utils.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(pnmenc.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(xbmenc.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(srtdec.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(xsubenc.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(utils.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(ffv1enc.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(huffyuvenc.o) : error LNK2001: unresolved external symbol _snprintf libavcodec.a(pamenc.o) : error LNK2001: unresolved external symbol snprintf libavformat.a(rtpproto.o) : error LNK2019: unresolved external symbol __chkstk_ms referenced in function _rtp_write libavformat.a(smoothstreamingenc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(wtv.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(gopher.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(http.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(rtsp.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(rtspenc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(rtspdec.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(sapdec.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(mpegaudiodsp.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(aviobuf.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(hls.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(mpegts.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(aaccoder.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(kbdwin.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(aacpsy.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(aacps.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(mpegvideo.o) : error LNK2001: unresolved external symbol .......... libavcodec.a(jpeg2000dec.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(jpeglsenc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(svq1enc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(utvideoenc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(huffyuvdec.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(4xm.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(fraps.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(mpegvideo_enc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(dnxhdenc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(dv.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(dvdec.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavcodec.a(ffv1enc.o) : error LNK2001: unresolved external symbol ___chkstk_ms libavformat.a(xwma.o) : error LNK2001: unresolved external symbol __udivdi3 libavformat.a(oggparseogm.o) : error LNK2001: unresolved external symbol __udivdi3 libavformat.a(nutdec.o) : error LNK2019: unresolved external symbol ___udivdi3 referenced in function _nut_read_header libavformat.a(r3d.o) : error LNK2001: unresolved external symbol __udivdi3 libavformat.a(tty.o) : error LNK2001: unresolved external symbol __udivdi3 libavformat.a(wavdec.o)

> referenced in function _mp3lame_encode_init libavcodec.a(libmp3lame.o)
> : error LNK2019: unresolved external symbol _lame_get_encoder_delay
> referenced in function _mp3lame_encode_init libavcodec.a(libmp3lame.o)
> : error LNK2019: unresolved external symbol _lame_get_framesize
> referenced in function _mp3lame_encode_init libavcodec.a(libmp3lame.o)
> : error LNK2019: unresolved external symbol _lame_encode_buffer_float
> referenced in function _mp3lame_encode_frame
> libavcodec.a(libmp3lame.o) : error LNK2019: unresolved external symbol
> _lame_encode_buffer referenced in function _mp3lame_encode_frame libavcodec.a(libmp3lame.o) : error LNK2019: unresolved external symbol
> _lame_encode_buffer_int referenced in function _mp3lame_encode_frame libavcodec.a(libmp3lame.o) : error LNK2019: unresolved external symbol
> _lame_encode_flush referenced in function _mp3lame_encode_frame libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _cmnMemAlloc referenced in function _aac_encode_init
> libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _cmnMemCopy referenced in function _aac_encode_init
> libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _cmnMemFree referenced in function _aac_encode_init
> libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _cmnMemSet referenced in function _aac_encode_init
> libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _cmnMemCheck referenced in function _aac_encode_init
> libavcodec.a(libvo-aacenc.o) : error LNK2019: unresolved external
> symbol _voGetAACEncAPI referenced in function _aac_encode_init
> libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_analysis_wrote referenced in function _oggvorbis_encode_frame libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_block_clear referenced in function _oggvorbis_encode_close libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_dsp_clear referenced in function _oggvorbis_encode_close libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_info_clear referenced in function _oggvorbis_encode_close libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_analysis_buffer referenced in function _oggvorbis_encode_frame libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_analysis_blockout referenced in function _oggvorbis_encode_frame libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol _vorbis_analysis referenced in function
> _oggvorbis_encode_frame libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol _vorbis_bitrate_addblock referenced in
> function _oggvorbis_encode_frame libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_bitrate_flushpacket
> referenced in function _oggvorbis_encode_frame
> libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_info_init referenced in function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_encode_setup_vbr referenced in function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_encode_setup_managed referenced in function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol _vorbis_encode_ctl referenced in function
> _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol _vorbis_encode_setup_init referenced in
> function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_analysis_init referenced
> in function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_block_init referenced in
> function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_comment_init referenced in
> function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_comment_add_tag referenced
> in function _oggvorbis_encode_init libavcodec.a(libvorbis.o) : error
> LNK2019: unresolved external symbol _vorbis_analysis_headerout
> referenced in function _oggvorbis_encode_init
> libavcodec.a(libvorbis.o) : error LNK2019: unresolved external symbol
> _vorbis_comment_clear referenced in function _oggvorbis_encode_init libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_vp8_cx_algo referenced in function _vp8_init libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_error referenced in function _log_encoder_error libavcodec.a(libvpxdec.o) : error LNK2001: unresolved external symbol
> _vpx_codec_error libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol _vpx_codec_error_detail referenced in function
> _log_encoder_error libavcodec.a(libvpxdec.o) : error LNK2001: unresolved external symbol _vpx_codec_error_detail
> libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_control_ referenced in function _codecctl_int libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_destroy referenced in function _vp8_free libavcodec.a(libvpxdec.o) : error LNK2001: unresolved external symbol
> _vpx_codec_destroy libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol _vpx_codec_version_str referenced in
> function _vp8_init libavcodec.a(libvpxdec.o) : error LNK2001:
> unresolved external symbol _vpx_codec_version_str
> libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_build_config referenced in function _vp8_init libavcodec.a(libvpxdec.o) : error LNK2001: unresolved external symbol
> _vpx_codec_build_config libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol _vpx_codec_enc_config_default referenced in
> function _vp8_init libavcodec.a(libvpxenc.o) : error LNK2019:
> unresolved external symbol _vpx_codec_err_to_string referenced in
> function _vp8_init libavcodec.a(libvpxenc.o) : error LNK2019:
> unresolved external symbol _vpx_codec_enc_init_ver referenced in
> function _vp8_init libavcodec.a(libvpxenc.o) : error LNK2019:
> unresolved external symbol _vpx_img_wrap referenced in function
> _vp8_init libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol _vpx_codec_encode referenced in function _vp8_encode
> libavcodec.a(libvpxenc.o) : error LNK2019: unresolved external symbol
> _vpx_codec_get_cx_data referenced in function _vp8_encode libavcodec.a(libvpxdec.o) : error LNK2019: unresolved external symbol
> _vpx_codec_vp8_dx_algo referenced in function _vp8_init libavcodec.a(libvpxdec.o) : error LNK2019: unresolved external symbol
> _vpx_codec_decode referenced in function _vp8_decode libavcodec.a(libvpxdec.o) : error LNK2019: unresolved external symbol
> _vpx_codec_get_frame referenced in function _vp8_decode libavcodec.a(libvpxdec.o) : error LNK2019: unresolved external symbol
> _vpx_codec_dec_init_ver referenced in function _vp8_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_bit_depth referenced in function _X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_close referenced in function _X264_close libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_param_default referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_param_default_preset referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_param_parse referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_param_apply_fastfirstpass referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_param_apply_profile referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_open_125 referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_headers referenced in function _X264_init libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_picture_init referenced in function _X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_reconfig referenced in function _X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_encode referenced in function _X264_frame libavcodec.a(libx264.o) : error LNK2019: unresolved external symbol
> _x264_encoder_delayed_frames referenced in function _X264_frame libavcodec.a(aacsbr.o) : error LNK2019: unresolved external symbol
> _exp2f referenced in function _ff_sbr_apply libavcodec.a(acelp_pitch_delay.o) : error LNK2001: unresolved external
> symbol _exp2f libavcodec.a(aacpsy.o) : error LNK2019: unresolved
> external symbol _atanf referenced in function _calc_bark
> libavcodec.a(aacps.o) : error LNK2001: unresolved external symbol
> _atanf libavformat.a(smoothstreamingenc.o) : error LNK2019: unresolved external symbol __imp___mkdir referenced in function _ism_write_header
> libavformat.a(wavenc.o) : error LNK2019: unresolved external symbol
> _strtoll referenced in function _wav_write_header libavformat.a(http.o) : error LNK2001: unresolved external symbol
> _strtoll libavutil.a(channel_layout.o) : error LNK2001: unresolved external symbol _strtoll libavformat.a(file.o) : error LNK2019:
> unresolved external symbol __imp___fstat64 referenced in function
> _file_seek libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol _RTMP_Socket referenced in function
> _rtmp_get_file_handle libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol _RTMP_SendSeek referenced in function
> _rtmp_read_seek libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol _RTMP_Pause referenced in function _rtmp_read_pause
> libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_Close referenced in function _rtmp_close libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_Write referenced in function _rtmp_write libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_Read referenced in function _rtmp_read libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol _RTMP_LogSetLevel
> referenced in function _rtmp_open libavformat.a(librtmp.o) : error
> LNK2019: unresolved external symbol _RTMP_LogSetCallback referenced in
> function _rtmp_open libavformat.a(librtmp.o) : error LNK2019:
> unresolved external symbol _RTMP_Init referenced in function
> _rtmp_open libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol _RTMP_SetupURL referenced in function _rtmp_open
> libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_Connect referenced in function _rtmp_open libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_ConnectStream referenced in function _rtmp_open libavformat.a(librtmp.o) : error LNK2019: unresolved external symbol
> _RTMP_EnableWrite referenced in function _rtmp_open libavutil.a(parseutils.o) : error LNK2019: unresolved external symbol
> ___strtod referenced in function _av_parse_color libavutil.a(eval.o) : error LNK2001: unresolved external symbol ___strtod
> libavutil.a(eval.o) : error LNK2019: unresolved external symbol _trunc
> referenced in function _eval_expr libavutil.a(time.o) : error LNK2019:
> unresolved external symbol _gettimeofday referenced in function
> _av_gettime libavutil.a(time.o) : error LNK2019: unresolved external symbol _usleep referenced in function _av_usleep

为了使用动态链接,我将所有的 .dll 文件复制到调试文件(创建主要可执行文件的地方)并更改主要 header 如下:

extern "C" 
{
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavfilter/avfilter.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include <libavresample/avresample.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>

#pragma comment(lib, "D:/VC Projects/libav/lib/libavutil.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libswscale.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavfilter.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavresample.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavcodec.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavdevice.dll.a")
#pragma comment(lib, "D:/VC Projects/libav/lib/libavformat.dll.a")
}

项目编译无误。但是在执行时它会显示错误消息“过程入口点 sws_getContext 无法位于动态链接库 avutil-52.dll 中”并退出。

我链接静态库的第一个目标失败了,动态链接也是如此。

我使用的是 Visual Studio 2008,操作系统是 Windows XP。

谁能找出我哪里犯了错误?

帕尼。

最佳答案

您需要 libav 项目的 .lib 和 .dll 文件。不幸的是,它们没有随 libav 一起提供,必须手动构建。

幸运的是,您可以从 this 下载它们页面。

  • .dll 文件在共享包中(bin 目录在 存档)
  • .lib 文件在开发包中(lib 目录)

关于c++ - 在 Visual Studio 2008 中链接 libav 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19057403/

相关文章:

haskell - 用 GHC 将小型 Haskell 程序编译成巨大的二进制文件

c++ - 如何在我的dll中集成第三方库?

c++ - 如何更改 QMessageBox 按钮的样式表?

c# - EmguCV 3.0 中的 CvInvoke.ConvexityDefects()

c++ - 使用 ffmpeg 对音频进行去量化

visual-studio-2008 - 使用Oracle.DataClient时provider与Oracle客户端版本不兼容报错

c++ - 完全静态构建具有所有依赖项(libgcc 等)的应用程序?

c++ - 用于简单消息的 XML C++ 库

visual-studio-2010 - 来自 Visual Studio 2010 的 Visual Studio 2008 项目,无需转换

c++ - Qt creator 中的 Pantheios 与 VS C++ 2008 编译器