undefined reference to

suggest change

This linker error happens, if the linker can’t find a used symbol. Most of the time, this happens if a used library is not linked against.

qmake:

LIBS += nameOfLib

cmake:

TARGET_LINK_LIBRARIES(target nameOfLib)

g++ call:

g++ -o main main.cpp -Llibrary/dir -lnameOfLib

One might also forget to compile and link all used .cpp files (functionsModule.cpp defines the needed function):

g++  -o binName main.o functionsModule.o

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Common compile linker errors:
* undefined reference to

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
94 Common compile linker errors
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype