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
/Usr/Lib/X86_64-Linux-Gnu/Libstdc++.So.6: Version Cxxabi_1.3.8' Not Found
How to Check What Shared Libraries Are Loaded at Run Time for a Given Process
Faster Bulk Inserts in SQLite3
How to Read File Content into Istringstream
C++11: How to Alias a Function
Why Is Allocator::Rebind Necessary When We Have Template Template Parameters
Know If .Lib Is Static or Import
How to Read-Write Into/From Text File with Comma Separated Values
C++11 Initializer List Fails - But Only on Lists of Length 2
Calling a Function for Each Variadic Template Argument and an Array
Why Does Cudamalloc() Use Pointer to Pointer
What's Faster, Iterating an Stl Vector with Vector::Iterator or with At()
Case Insensitive Std::String.Find()
C++ Convert Vector<Int> to Vector<Double>
Qt Signals (Queuedconnection and Directconnection)
How Does C++ Stl Unordered_Map Resolve Collisions
How to Redefine a C++ MACro Then Define It Back
Is There Any Guarantee of Alignment of Address Return by C++'s New Operation