0
votes

Merry Christmas, everybody,

I’m coding ffmpeg with gcc.

But, on the build process, I met the errors of ‘undefined reference to xxxxx’ for all functions that I coded in my program, and I recognized that it was due to the libxxx.a file.

And the every adviser on internet suggested that check the directory for the files.

So, I searched the files in which include the function names in my computer, and I found the .a files are correctly set in the directory which I coded.

And there are the other files which are named ‘libxxx.dll.a’, so I tried to build with the files ‘libxxx.dll.a’, but I got the same result.

On this point, I have got some questions.

1) If the gcc could not find the libxxx.a files, it would say that ‘cannot find the –lxxx’. But it just said ‘undefined reference to xxxx’. It means that those libxxx.a files are in the correct directories.

2) And if the files do not define the functions, it is strange. Because those files include the function names and are the same files/directories I had searched in my computer, and I think it should have the definitions of the functions. But I am not sure that the files define the functions or not, because I cannot read the file myself.

If I am wrong, what was my mistake?

3) Can libxxxlib.a files be replaced with the libxxx.a? And if it can, what is the difference between libxxxlib.a and libxxx.a? And the same for the libz and libzlib?a

Here is my line commend, the directory which include the libxxx.a files.

g++ -o C:\ffmpeg\ffmpegTest C:\ffmpeg\ffmpegTest.cc -IC:\ffmpeg -LC:\ffmpeg\3rdparty\lib -lavutil -lavformat -lavcodec -lz -lavutil -lm -D__STDC_CONSTANT_MACROS

C:\ffmpeg\3rdparty\lib

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0xec>: undefined reference to 'av_register_all()'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x11c>: undefined reference to 'av_open_input_file(AVFormatContext*, char const, AVInputFormat*, int, AVFormatParameters*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x13b>: undefined reference to 'av_find_stream_info(AVFormatContext*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x174>: undefined reference to 'dump_format(AVFormatContext, int, char const*, int)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x224>: undefined reference to 'avcodec_find_decoder(CodecID)'

and all the errors are

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x281>: undefined reference to 'avcodec_open(AVCodecContext*, AVCodec)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x297>: undefined reference to 'avcodec_alloc_frame()'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x2a3>: undefined reference to 'avcodec_alloc_frame()'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x2e6>: undefined reference to 'avpicture_get_size(PixelFormat,int,int)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x2fc>: undefined reference to 'av_malloc(unsigned int)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x341>: undefined reference to 'avpicture_fill(AVPicture*, unsigned char*, PixelFormat, int, int)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x38c>: undefined reference to 'avcodec_decode_video2(AVCodecContext, AVFrame*, int, AVPacket*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x409>: undefined reference to 'sws_getContext(int, int, PixelFormat, int, int, PixelFormat, int, SwsFilter*, swsFilter*, double const*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x463>: undefined reference to 'sws_scale(SwsContext*, unsigned char const* const*, int const*, int, int, unsigned char* const*, int const*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x4bb>: undefined reference to 'av_free_packet(AVPacket*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x4cf>: undefined reference to 'av_read_frame(AVFormatContext, AVPacket*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x36c>: undefined reference to 'av_free(void*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x36c>: undefined reference to ' avcodec_close(AVCodecContext*)'

C:\Users\AppData\Local\Temp\ccVHLzjK.o:ffmpegTest.cc:<.text+0x36c>: undefined reference to 'av_close_input_file(AVFormatContext)'

1

1 Answers

0
votes

You should post your exact error message (or at least the first few lines of it).

Most likely you are a victim of C++ name mangling.

The undefined reference to ... almost certainly has nothing to do with any missing files.