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
3
votes
2 answers

MinGW Win32 + nasm: "undefined reference"

I am currently developing an OS for learning purposes, and it's been working fine until now. Then I tried to call an assembler function, compiled with nasm, -fwin32, from C code, but all I got was an "undefined reference" error. I have created a…
Jan Weber
  • 137
  • 13
3
votes
1 answer

Several "undefined reference to" errors

I'm editing the source code for a Computational Fluid Dynamics program and although I'm new to C++ I cannot seem to work out where the errors are coming from. They are as follows: Make/linux64GccDPOpt/mySTCompressibleInterFoam.o: In function…
jd210
  • 33
  • 4
3
votes
1 answer

Undefined reference: dll -> free function -> overloaded operator -> templated struct

I can't build the right words for it to call, so I made the title like that. I have this DLL in which the templated structs are inside in a namespace with defined overloaded operators that are non-member(free function) of those…
mr5
  • 3,438
  • 3
  • 40
  • 57
3
votes
0 answers

Eigen 'undefined reference to' error when -O2 is set

I'm having some trouble getting Eigen to compile with optimisations -O2 set. If I swap the -O2 for -g compilation completes, and the program runs without error. With -O2 set, the linker throws out the below: build/main.o:main.cpp:function…
joeButler
  • 1,643
  • 1
  • 20
  • 41
3
votes
2 answers

Notice: Undefined property: stdClass error on front end

I can't figure out how to make this line defined. If anyone can offer assiatnce that would be appreciated, probably something very simple. This line: $value = $value->published; Keeps giving me this error - Notice: Undefined property:…
Matt Weick
  • 332
  • 6
  • 19
3
votes
1 answer

Undefined References to _imp____glew* functions with minGW gcc

I am trying to compile a relatively simple OpenGL program using MinGW on a Win 7 x64 system, and I keep getting undefined references to several of the GLEW functions. I have set the libraries to link to the programs, and have been looking around…
Caleb Waggoner
  • 147
  • 1
  • 2
  • 13
3
votes
1 answer

C++ undefined reference though function is defined in the same file

I'm currently trying to write a OpenGL program in C++. When I try to compile my program I get undefined references, everywhere where i call member functions of my class, although I call these functions from member functions... These are the error…
Horstinator
  • 548
  • 1
  • 5
  • 18
3
votes
2 answers

Global variables and linking problems

My mostly header based library makes use of a global variable placed in the library's namespace (BigNum). The definition of the variable is as follows: namespace BigNum{ /** * __Some lower powers of ten prestored for fast runtime lookup.__*/ const…
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
3
votes
2 answers

C++ template class static const variable member as map key gives undefined reference

I have a bunch of classes that have a static member that is an enum value. And I have a map somewhere else with this enum as key. Now if I use a template parameter in a function to access the map, I get an undefined reference. To make it clear, here…
Pluc
  • 901
  • 8
  • 21
3
votes
1 answer

OpenCV 2.4.1 static linking with Qt

I have compile OpenCV 2.4.1 statically without error using MinGW and CMake. I checked With_QT I just unchecked BUILD_SHARED_LIBS and proceed with mingw32-make and mingw32-make install. It was built without error and eventually I have bunch of .a…
3
votes
1 answer

Autoconf with boost test - linker issue

I'm facing an issue with boost unit_test framework along with autoconf & automake... Here's about the project structure: ./include/com_i_foo.h ./include/com_foo.h ... class FooSingleton { protected: FooSingleton() {} private: …
Syffys
  • 570
  • 5
  • 21
3
votes
1 answer

Undefined references when statically linking C++ and C libraries

I have 3 libraries I am trying to link (more than that, but all that is needed for this explanation). The "root" library is c++, which has the second library as a dependency for it and is also c++. The third library is c and is a dependent of the…
Mako_Energy
  • 352
  • 2
  • 19
3
votes
3 answers

creating threads in C

I am trying to run this C program using gcc -Wall -std=c99 hilo.c - ./a.out hilo.c and I am getting this error message: hilo.c: In function ‘func’: hilo.c:6:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘pthread_t’…
user2188946
  • 35
  • 1
  • 1
  • 4
3
votes
2 answers

GCC complains about missing references to functions in the same file

Running along the makefile, I get to this: cc client.o MurmurHash3.o libstorage.a -Wall -lreadline -pthread -o client MurmurHash3.o: In function `MurmurHash3_x64_128': /home/evantandersen/mount/src/MurmurHash3.c:59: undefined reference to…
charliehorse55
  • 1,940
  • 5
  • 24
  • 38
3
votes
2 answers

android ndk undefined reference to a method

Hi Sorry for the long post I am trying to compile some static classes namely jsmn.c,json.c and buf.c which are part of the jsmn json library I downloaded from https://github.com/alisdair/jsmn-example/downloads. I am compiling two STATIC_LIBRARIES…