Gcc: Undefined Reference To

gcc: undefined reference to

However, avpicture_get_size is defined.

No, as the header (<libavcodec/avcodec.h>) just declares it.

The definition is in the library itself.

So you might like to add the linker option to link libavcodec when invoking gcc:

-lavcodec

Please also note that libraries need to be specified on the command line after the files needing them:

gcc -I$HOME/ffmpeg/include program.c -lavcodec

Not like this:

gcc -lavcodec -I$HOME/ffmpeg/include program.c

Referring to Wyzard's comment, the complete command might look like this:

gcc -I$HOME/ffmpeg/include program.c -L$HOME/ffmpeg/lib -lavcodec

For libraries not stored in the linkers standard location the option -L specifies an additional search path to lookup libraries specified using the -l option, that is libavcodec.x.y.z in this case.


For a detailed reference on GCC's linker option, please read here.

gcc undefined reference to

test: polynomial.o counting.o matrix.o
gcc -Wall -Werror test.c -o test polynomial.o counting.o -g -std=c99

should be

test: polynomial.o counting.o matrix.o
gcc -Wall -Werror test.c -o test polynomial.o counting.o matrix.o -g -std=c99

undefined reference issue with latest gcc

Reported this bug to GCC Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105848

Undefined reference to stdscr

You could use -lcurses. Ex: gcc main.c -o demo -lcurses

In C, what constitutes an undefined reference to a symbol?

Including the header file just declares the symbols, it does not define them -- they'll be undefined in your test.c compilation unit because it does not ever define them.

The read symbol is in fact defined in libc.so -- the C standard library -- but when linking your program it first sees your compilation unit (test.o) at which point read is still undefined. So the references to read are instead mapped to __wrap_read.

definitions and declarations are two different things. Related, but different.

gcc: undefined reference to function

You should compile and link with -pthread



Related Topics



Leave a reply



Submit