I'm trying to compile program but getting strange error don't know why.
> c++ src/main.cpp.o -o test -lavformat -lavcodec -lavdevice -lavutil -lswscale -lpthread
/usr/bin/ld: src/main.cpp.o: undefined reference to symbol 'avcodec_receive_packet@@LIBAVCODEC_57'
//usr/local/lib/libavcodec.so.57: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
But When I find inspect /usr/local/lib/libavcodec.so.57
with nm
, I get following output
> nm /usr/local/lib/libavcodec.so.57 | grep avcodec_receive_packet
0000000000630590 T avcodec_receive_packet
It's strange why c++
couldn't detect avcodec_receive_packet
Update:
Since I'm using C
from C++
, C
code is enclosed with extern
keyword
extern "C" {
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
}