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
-1
votes
1 answer

error: ld returned 1 exit status at C

I 've compiled my CSMA-CD simulator both in DEV c++ and at an online compiler but i get the same error and i do not know how to fix it. Any ideas? #include #include #include #define MAX_STATIONS 10 #define BUS_RATE…
Fenriz
  • 3
  • 1
-1
votes
1 answer

undefined reference errors again

My program won't compile correctly. It gives undefined errors. Can someone help me solving that? It says C:\Users\Milan_2\AppData\Local\Temp\ccQt3lVs.o In function 'orderOnConveyer': 90 C:\Users\Milan_2\Desktop\Untitled2.c undefined …
Kingsman
  • 11
  • 1
  • 1
  • 4
-1
votes
1 answer

C Header files not working?

I can't get my runner.c to see my mergesort.h import, just the last thing I need to do before I go through and add in comments. Not seeing what I am doing wrong here so I thought I'd get more eyes to look at it. I looked up questions on here and…
Carson
  • 1,147
  • 5
  • 19
  • 41
-1
votes
1 answer

Warning: Undefined reference to function

I keep getting the warning that my function has an undefined reference and that doesn't really say much to me or how to fix it. Here are the errors log_2.c: In function ‘main’: log_2.c:29: warning: implicit declaration of function ‘logbase2’…
user3457828
  • 23
  • 1
  • 4
-1
votes
1 answer

Undefined reference

I'm trying compile and run simple code presented below #include class Date { int d,m,y; static Date default_date; public: Date(int dd=0, int mm=0, int yy=0); static void set_default(int d, int m, int…
Leopoldo
  • 795
  • 2
  • 8
  • 23
-1
votes
1 answer

Undefined reference in Kdevelop

I have main.cpp, linking test function from io.c #include #include "io.h" int main(int argc, char **argv) { test(); return 0; } io.c: #include #include "io.h" void test() { printf("hee"); } and I configure…
-1
votes
2 answers

C++ error "undefined reference to" when compiling test code

I've been trying to compile my code and finally got it down to just one error. If someone could explain whats going it would be great! Here is my header file rates.h #ifndef RATES_H #define RATES_H #include namespace power { //! Energy…
HockeyChat
  • 11
  • 4
-1
votes
1 answer

Undefined reference to class::method

In these days I thought I would try to work on some C++ Object Oriented Programming by converting one of my old programs to an object which methods I could use in other programs. The program is able to get an array of strings and print them to make…
-1
votes
3 answers

Undefined reference?

I am getting an undefined reference error. I've stared at this code for about an hour trying to figure it out. This is the error I get. undefined reference to fileToArray(std::basic_fstream >&, int*, int) This is my…
-1
votes
1 answer

Undefined reference error in c++ dynamic member

hi everyone im new to programming so excuse the noob question... i tried every method to get through with the undefined refernce error but it keeps throwing that error at me i tried using pointer "->" and the "::" sign and also the dot "." what am i…
-1
votes
3 answers

Undefined reference to defined function

I have a very weird error: I have a pair of .h and .cpp files that contain some functions and constants. When I try to compile it, g++ says "undefined reference" to the function. The function prototype and definition seem to be the same. I have…
calccrypto
  • 8,583
  • 21
  • 68
  • 99
-1
votes
1 answer

error: undefined reference to `vector::pushBack(int const&)'

I create a vector class and in qt I wrote this code this is a click action I am trying to add new value in vector with click action void MainWindow::manuelclick() { int b=0; vector a; a.pushBack(10); for(int…
cihad
  • 72
  • 3
  • 9
-1
votes
6 answers

C++ undefined reference to function?

I've defined a public template function in a class called EventDispatcher: public: template void AddEventListener ( className* ); The function implements like this: template void…
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
-1
votes
2 answers

Undefined reference error for static member function

Possible Duplicate: C++: undefined reference to static class member My goal here is to make a container object that will hold objects. I've decided to use a vector of pointers to do this. Apart from the container object, there will be an abstract…
mathmax
  • 37
  • 1
  • 8
-1
votes
3 answers

Undefined reference to C++ libraries

I'm trying to compile a library with a test.cpp file, but even though i get all the includes needed, i still get: test.cpp:(.text+0x24): undefined reference to `initdevice(char*)' test.cpp:(.text+0x4c): undefined reference to `write2device(char*,…
Itzik984
  • 15,968
  • 28
  • 69
  • 107