Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking libavcodec and libavformat: Undefined references

I am trying to compile a project I am working on that uses ffmpeg libraries. The project is written in C. The header files are appropriately included in the source code. In particular, it seems to be using libavcodec and libavformat, and these libraries are appropriately linked in the Makefile with the LDFLAGS. Here are the flags used:

-lavcodec -lavformat -lswscale -lavutil

Now, because the packaged libraries that come with Ubuntu were too out-of-date, I downloaded the latest source code for ffmpeg, compiled it and installed it. I removed all of the packaged libraries that were installed via the package manager. Now, despite adding the flags above, I get a lot of undefined references and I cannot seem to fix it. Here is the output with regard to the undefined references:

//usr/local/lib/libavcodec.a(cscd.o): In function `decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/cscd.c:91: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(dxa.o): In function `decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/dxa.c:250: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(exr.o): In function `pxr24_uncompress':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:784: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(exr.o): In function `zip_uncompress':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:259: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_block':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:191: undefined reference to `inflateReset'
//usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv2_prime':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:158: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:160: undefined reference to `deflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:166: undefined reference to `deflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:167: undefined reference to `deflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:169: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:178: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_block':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:207: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:210: undefined reference to `inflateSync'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:211: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(flashsv.o): In function `calc_deflate_block_size':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:259: undefined reference to `deflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:261: undefined reference to `deflateBound'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:262: undefined reference to `deflateEnd'
//usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:107: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:126: undefined reference to `inflateInit_'
//usr/local/lib/libavcodec.a(flashsv2enc.o): In function `encode_zlib':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv2enc.c:354: undefined reference to `compress2'
//usr/local/lib/libavcodec.a(flashsv2enc.o): In function `encode_zlibprime':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv2enc.c:366: undefined reference to `deflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv2enc.c:375: undefined reference to `deflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv2enc.c:384: undefined reference to `deflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv2enc.c:385: undefined reference to `deflateEnd'
//usr/local/lib/libavcodec.a(flashsvenc.o): In function `encode_bitstream':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsvenc.c:190: undefined reference to `compress2'
//usr/local/lib/libavcodec.a(flashsvenc.o): In function `flashsv_encode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsvenc.c:95: undefined reference to `deflateEnd'
//usr/local/lib/libavcodec.a(g2meet.o): In function `kempf_decode_tile':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/g2meet.c:408: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(lcldec.o): In function `zlib_decomp':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:137: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:146: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:137: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:146: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:137: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:146: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(lcldec.o): In function `decode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:647: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(lcldec.o): In function `decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lcldec.c:623: undefined reference to `inflateInit_'
//usr/local/lib/libavcodec.a(lclenc.o): In function `encode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:80: undefined reference to `deflateBound'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:90: undefined reference to `deflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:101: undefined reference to `deflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:107: undefined reference to `deflate'
//usr/local/lib/libavcodec.a(lclenc.o): In function `encode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:184: undefined reference to `deflateEnd'
//usr/local/lib/libavcodec.a(lclenc.o): In function `encode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/lclenc.c:165: undefined reference to `deflateInit_'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:376: undefined reference to `swr_is_initialized'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:222: undefined reference to `swr_is_initialized'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_init_resample':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:163: undefined reference to `swr_init'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:169: undefined reference to `swr_convert'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:236: undefined reference to `swr_convert'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_flush_resample':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:117: undefined reference to `swr_convert'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:408: undefined reference to `swr_close'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_flush':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:563: undefined reference to `swr_close'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_close':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:585: undefined reference to `swr_free'
//usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/opusdec.c:638: undefined reference to `swr_alloc'
//usr/local/lib/libavcodec.a(pngdec.o): In function `decode_zbuf':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:425: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:439: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:448: undefined reference to `inflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:453: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(pngdec.o): In function `png_decode_idat':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:393: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(pngdec.o): In function `decode_frame_apng':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:1179: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:1203: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(pngdec.o): In function `decode_frame_png':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:1126: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngdec.c:1142: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(pngenc.o): In function `png_write_chunk':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:200: undefined reference to `crc32'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:202: undefined reference to `crc32'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:205: undefined reference to `crc32'
//usr/local/lib/libavcodec.a(pngenc.o): In function `encode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:298: undefined reference to `deflateInit2_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:303: undefined reference to `deflateBound'
//usr/local/lib/libavcodec.a(pngenc.o): In function `png_write_row':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:220: undefined reference to `deflate'
//usr/local/lib/libavcodec.a(pngenc.o): In function `encode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:447: undefined reference to `deflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:422: undefined reference to `deflate'
//usr/local/lib/libavcodec.a(pngenc.o): In function `png_write_row':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:220: undefined reference to `deflate'
//usr/local/lib/libavcodec.a(pngenc.o): In function `png_write_chunk':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:200: undefined reference to `crc32'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/pngenc.c:202: undefined reference to `crc32'
//usr/local/lib/libavcodec.a(svq3.o): In function `svq3_decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/svq3.c:1016: undefined reference to `uncompress'
//usr/local/lib/libavcodec.a(tiff.o): In function `tiff_uncompress':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tiff.c:329: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tiff.c:334: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tiff.c:335: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(tiffenc.o): In function `encode_strip':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tiffenc.c:175: undefined reference to `compress'
//usr/local/lib/libavcodec.a(tscc.o): In function `decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tscc.c:77: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tscc.c:86: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(tscc.o): In function `decode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tscc.c:173: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(tscc.o): In function `decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/tscc.c:155: undefined reference to `inflateInit_'
//usr/local/lib/libavcodec.a(zerocodec.o): In function `zerocodec_decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zerocodec.c:56: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zerocodec.c:79: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(zerocodec.o): In function `zerocodec_decode_close':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zerocodec.c:109: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(zerocodec.o): In function `zerocodec_decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zerocodec.c:127: undefined reference to `inflateInit_'
//usr/local/lib/libavcodec.a(zmbv.o): In function `decode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbv.c:486: undefined reference to `inflateReset'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbv.c:523: undefined reference to `inflate'
//usr/local/lib/libavcodec.a(zmbv.o): In function `decode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbv.c:616: undefined reference to `inflateEnd'
//usr/local/lib/libavcodec.a(zmbv.o): In function `decode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbv.c:601: undefined reference to `inflateInit_'
//usr/local/lib/libavcodec.a(zmbvenc.o): In function `encode_frame':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbvenc.c:224: undefined reference to `deflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbvenc.c:215: undefined reference to `deflateReset'
//usr/local/lib/libavcodec.a(zmbvenc.o): In function `encode_end':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbvenc.c:259: undefined reference to `deflateEnd'
//usr/local/lib/libavcodec.a(zmbvenc.o): In function `encode_init':
/home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/zmbvenc.c:321: undefined reference to `deflateInit_'
//usr/local/lib/libavformat.a(rtmpproto.o): In function `rtmp_uncompress_swfplayer':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/rtmpproto.c:1097: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/rtmpproto.c:1107: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/rtmpproto.c:1125: undefined reference to `inflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/rtmpproto.c:1125: undefined reference to `inflateEnd'
//usr/local/lib/libavformat.a(swfdec.o): In function `swf_read_packet':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/swfdec.c:335: undefined reference to `uncompress'
//usr/local/lib/libavformat.a(swfdec.o): In function `swf_read_header':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/swfdec.c:124: undefined reference to `inflateInit_'
//usr/local/lib/libavformat.a(swfdec.o): In function `zlib_refill':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/swfdec.c:92: undefined reference to `inflate'
//usr/local/lib/libavformat.a(swfdec.o): In function `swf_read_close':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/swfdec.c:502: undefined reference to `inflateEnd'
//usr/local/lib/libavformat.a(http.o): In function `http_close':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/http.c:1093: undefined reference to `inflateEnd'
//usr/local/lib/libavformat.a(http.o): In function `parse_content_encoding':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/http.c:419: undefined reference to `inflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/http.c:420: undefined reference to `inflateInit2_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/http.c:425: undefined reference to `zlibCompileFlags'
//usr/local/lib/libavformat.a(http.o): In function `http_buf_read_compressed':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/http.c:902: undefined reference to `inflate'
//usr/local/lib/libavformat.a(id3v2.o): In function `id3v2_parse':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/id3v2.c:900: undefined reference to `uncompress'
//usr/local/lib/libavformat.a(matroskadec.o): In function `matroska_decode_buffer':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/matroskadec.c:1212: undefined reference to `inflateInit_'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/matroskadec.c:1227: undefined reference to `inflate'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/matroskadec.c:1220: undefined reference to `inflateEnd'
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/matroskadec.c:1232: undefined reference to `inflateEnd'
//usr/local/lib/libavformat.a(mov.o): In function `mov_read_cmov':
/home/abhijitv/Downloads/ffmpeg-2.5/libavformat/mov.c:3146: undefined reference to `uncompress'
collect2: error: ld returned 1 exit status

Can anyone explain what is going wrong over here, and how I can fix this?

like image 861
lite-whowantstoknow Avatar asked Dec 08 '14 20:12

lite-whowantstoknow


1 Answers

You're missing some libraries.
Append:

-lswresample -lm -lz

like image 136
egur Avatar answered Nov 13 '22 08:11

egur