In program.c, I would like to use a method 'avcodec_register_all()' defined in libavcodec/avcodec.h.
Running
gcc program.c -L$HOME/ffmpeg/lib/libavfilter.a -L$HOME/ffmpeg/lib/libavcodec.a
Gives me an error
/tmp/ccNeQywU.o: In function `main':
program.c:(.text+0x3f): undefined reference to `avcodec_register_all'
collect2: ld returned 1 exit status
Spelling is correct and the function is defined. Why is this happening?
program.c
#include <stdio.h>
int main (int args, char *argv[])
{
avcodec_register_all();
}
It is like this
gcc -static -lavfilter -lavcodec -L/HOME/ffmpeg/lib/
You need to include the file avcodec.h
and also add the path to that file in your include path flags to gcc.
gcc -static -lavfilter -lavcodec -L$HOME/ffmpeg/lib/ -I$HOME/ffmpeg/include
The static is given because your are trying to use a *.a library and not *.so (dynamic).
使用-lavcodec
和现有参数来gcc
One of the reasons may be that the function avcodec_register_all()
is defined in a C++ file. It should be defined as extern "C"
in avcodec.h
and the library should be compiled with this proper avcodec.h
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.