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
0
votes
0 answers

Undefined reference to methods in a certain class using templates c++

I have a class called SomeClass with a template someclass.hpp template SomeClass { public: SomeClass(T& it, int a): t(it), b(a) { CallMethod(); } static void PrintSomething() { std::cout << "static method in…
user592748
  • 1,194
  • 3
  • 21
  • 45
0
votes
1 answer

Undefined reference in g++ linking

Every time I make a new module and try to link it to my main class (Estudiant.o) using this line: g++ -o red1.exe red1.o %OBJETOS_CPP%\Estudiant.o I get this error: red1.o:red1.cpp:(.text+0xd): undefined reference to Estudiant::consultar_DNI()…
Buradi
  • 63
  • 1
  • 2
  • 9
0
votes
1 answer

C++ Phidget eventhandler undefined reference 'linker'

I am getting the following errors. Based on the last line I believe it a linker error. However, I really don't know what I am talking about. :) I'm a beginner. If you happen to spot any other crappy points please let me know! error: undefined…
atomSmasher
  • 1,465
  • 2
  • 15
  • 37
0
votes
4 answers

Function declared in header not accessible in main file

I have a file structure as follows: interface.h --> interface.c | | effects.h --> effects.c | | main However, functions declared in effects.h are not accessible in main. Code snippets : main : #include…
asheeshr
  • 4,088
  • 6
  • 31
  • 50
0
votes
1 answer

undefined reference to Class::method()

I'm using a framework called ROOT in my code, ROOT provides a large amount of libs, between then there is PROOF which should allow my code run in parallel. Should be defined in TProof.h a static method Open that starts the parallel environment. I'm…
RSFalcon7
  • 2,241
  • 6
  • 34
  • 55
0
votes
1 answer

referencing global variables from inline assembly in gcc

I have the problem where the linker generates undefined reference errors from the inline assembly code. int global_var = 0; void myfunc() { asm(".intel_syntax noprefix\n"); asm("lea eax, global_var\n"); } I am compiling with -masm=intel and…
Vladimir Gazbarov
  • 860
  • 1
  • 10
  • 25
0
votes
1 answer

cuda undefined reference to __constant__ array

i got the following problem using nvcc. I use separate compilation (finally got it running with cmake) and got a problem with the declaration of a __device__ __constant__ (extern) type1 var[length] array. Here is my header: #include…
soriak
  • 672
  • 2
  • 13
  • 23
0
votes
0 answers

undefined reference - each object file compiles, but link fails

Possible Duplicate: static variable link error What is an undefined reference/unresolved external symbol error and how do I fix it? Sorry for adding yet another "undefined reference to" makefile problem post, but I couldn't find a solution even…
cmo
  • 3,762
  • 4
  • 36
  • 64
0
votes
1 answer

undefined reference to ... - linking issues?

I don't know what I'm getting the following error: proc1.o: In function `procEx1': /cygdrive/c/armprojects/projekt/motor/proc1.c:45: undefined reference to `motorTest_test' collect2: ld returned 1 exit status make: *** [main.hex] Error 1 I've…
Petrus K.
  • 840
  • 7
  • 27
  • 56
0
votes
1 answer

included cpufreq.h but shows linker error in linux c++

My problem is I am getting an undefined reference error in linux g++ cpufreq.h is in usr/include directory and I included #include . This has declaration for cpufreq_get_freq_kernel() But when I call cpufreq_get_freq_kernel(), it gets a…
0
votes
1 answer

Cygwin g++ build error: undefined reference to

I was trying to build a project (rar file) with NetBeans cygwin g++ compiler. I could build it by running make in the src/ directory under ubuntu. However, under cygwin, it kept giving me undefined reference to.... (Before compiling, I had changed…
Trantor Liu
  • 8,770
  • 8
  • 44
  • 64
0
votes
0 answers

Undefined reference to namespace::class::constructor

I have the following code, and every time I compile, it's giving me an error saying that there is an undefined reference to ns::player::player() This has never happened to me before, so to be honest, I'm quite confused. I just know it's something…
Kyle R.
  • 1,159
  • 2
  • 8
  • 5
0
votes
1 answer

Using an image map in Dreamweaver CS5 with a Jquery plugin

I'm currently trying to use an image map on a webpage I am building. When I draw the maps and add links, the page takes me to an an error for an "undefined" web address. I have multiple hotspots in one image, and I believe something with the jQuery…
0
votes
1 answer

Linker error: undefined reference to

I keep getting the following: [Linker error] undefined reference to `ComponentClass::POSIZIONENULLA' ld returned 1 exit status [Build Error] [main.exe] Error 1 can somebody help me with this. Here is my code: ComponentClass.h #ifndef…
geraldCelente
  • 1,005
  • 2
  • 16
  • 36
0
votes
3 answers

Undefined Reference for Pthread function in C

Possible Duplicate: undefined reference to pthread_create in linux (c programming) I am trying to implement Thread chain in Ubuntu in C. When I compile the following code, I get the errors of Undefined reference to these thread library function…
Alfred
  • 1,543
  • 7
  • 33
  • 45