Questions tagged [undefined-reference]

A linker error caused by a missing definition of a symbol used elsewhere in a program

The most common causes are

  • Declaring but not defining a function, global variable or static data member
  • Not compiling or linking to an object file that contains the definition of a symbol
  • Forgetting to link to the library that provides the symbol
  • Listing a required library before the objects that depend on it (in the linker command libraries should be listed after the objects that depend on them)

There is a C++ FAQ question about undefined references in C++ and how to solve them.

1243 questions
21
votes
5 answers

Undefined reference to SSL_library_init and SSL_load_error_strings

I am implementing a OpenSSL code and have already included required header files but still I am getting errors like * undefined reference to SSL_library_init I guess it's a linking error rather than a compilation error. I am implementing it in…
samprat
  • 2,150
  • 8
  • 39
  • 73
19
votes
5 answers

Qt: Signals and slots Error: undefined reference to `vtable for

Following example from this link: http://developer.kde.org/documentation/books/kde-2.0-development/ch03lev1sec3.html #include #include #include using namespace std; class MyWindow : public QWidget { Q_OBJECT …
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
18
votes
7 answers

OpenCV - undefined reference: SurfFeatureDetector and BruteForceMatcher

I'm making a program in C++ that uses 2 images to detect SURF Features, compute the matches with a bruteforcematcher and draws it. Here's the code #include #include #include #include "opencv/cv.h" #include…
Lennart-
  • 519
  • 1
  • 6
  • 19
18
votes
7 answers

Undefined reference to mempcy@GLIBC_2.14 when compiling on Linux

I am trying to port an application to drive a device that uses an ftdi2332h chip from windows to linux. I installed the libftd2xx library on an ubuntu 10.04 system per these instructions. When I try to compile any of the sample programs I get the…
user1487551
  • 391
  • 2
  • 3
  • 8
16
votes
2 answers

Undefined reference C++

I'm trying to compile my first legit program that I'm converting from Java (I ran a test hello world type program to check my compiler and it works). There are three files: main.cpp #include #include "skewNormal.h" using namespace…
Ryan Amos
  • 5,422
  • 4
  • 36
  • 56
16
votes
5 answers

Undefined reference to printf when using GCC cross compiler

I'm trying to get the following simple 'Hello World' program to compile using a cross compiler (GCC 4.9.2) targeting mips: #include int main() { int x = 5; printf("x = %d\n", x); } The x variable is there to stop GCC changing printf…
pwaring
  • 3,032
  • 8
  • 30
  • 46
16
votes
2 answers

Undefined Reference issues using Semaphores

I am playing around with using Semaphores, but I keep encountering Undefined Reference warnings, thus causing my code not to work. I pulled example code from a text, but was having issues with some of their syntax, so I went to POSIX's semaphore…
TheFatness
  • 349
  • 1
  • 5
  • 12
15
votes
6 answers

Is there a sequence point between these assignments?

Is there a sequence point between the two assignments in the following code: f(f(x=1,1),x=2);
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
15
votes
3 answers

g++ compile error: undefined reference to a shared library function which exists

I recently installed the hdf5 library on an ubuntu machine, and am now having trouble linking to the exported functions. I wrote a simple test script readHDF.cpp to explain the issue: #include int main(int argc, char * argv[]) { hid_t …
dermen
  • 5,252
  • 4
  • 23
  • 34
15
votes
4 answers

Undefined reference to 'yylex()'

I'm trying to use flex and bison to create a simple scripting language. Right now, I'm just trying to get a calculator working. I can't get it to compile, though. When I run this makefile: OBJECTS = hug.tab.o hug.yy.o PROGRAM = hug.exe CPP =…
Micah
  • 183
  • 1
  • 2
  • 9
14
votes
3 answers

C-callback to function template: explicitly instantiate template

Premise I’m using a C library (from C++) which provides the following interface: void register_callback(void* f, void* data); void invoke_callback(); Problem Now, I need to register a function template as a callback and this is causing me problems.…
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
14
votes
2 answers

Another "undefined reference" error when linking boost libraries

I've seen several other posts that deal with this exact same issue. However, none of their solutions seem to work for me. I am compiling the following code: #include #include #include…
Joshua Hewlett
  • 165
  • 1
  • 1
  • 7
13
votes
1 answer

Undefined reference to log10 function

I am building using Eclipse Kepler, and have included math.h. However, I am getting an error 'undefined reference to log10'. Also types uint8_t and unit32_t are not being resolved. I have included both stdint.h and inttypes.h, just to be sure,…
Aanchal Sahdev
  • 131
  • 1
  • 1
  • 5
13
votes
4 answers

C code compiled with C++: undefined reference

I have a small program that I can compile with GCC and ICC without any difficulties, but I would also like the code to work with G++ and ICPC. I tried to add this: #ifdef __cplusplus extern "C" { #endif at the beginning and this: #ifdef…
Suugaku
  • 2,667
  • 5
  • 31
  • 33
12
votes
2 answers

undefined reference when using experimental/filesystem

I am trying to compile a project with experimental::filesystem in visual studio code using code runner, however I can't get it to compile even in the terminal. The code is as follows, a very simple test usage from the docs: #include…
The Wizard Alt
  • 123
  • 1
  • 5
1 2
3
82 83