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

C++ what are garbled undefined reference errors telling me?

Can anyone help me understand what is creating these error messages? undefined reference to `_imp___ZN2sf6Sprite14setTextureRectERKNS_4RectIiEE' undefined reference to `_imp___ZN2sf7TextureD1Ev' undefined reference to…
A.B.
  • 15,364
  • 3
  • 61
  • 64
0
votes
1 answer

Undefined reference in C++ simple project

I'm trying to compile not mine project. I get this error: [sophie@laptop minit]$ g++ -o minit minit.cpp /tmp/ccxr5oWl.o: In function `main': minit.cpp:(.text+0x4e6): undefined reference to…
Sophie Sperner
  • 4,428
  • 8
  • 35
  • 55
0
votes
1 answer

Not able to locate error cpp linux

This maybe really stupid, but I faced the following error, while trying to compile certain code modules, using cmake acg_localizer_active_search.cc:(.text+0x43c6): undefined reference to `ANNkd_tree::ANNkd_tree(float**, int, int,…
0
votes
3 answers

C++: Calling a templated function from main()

It's the first time that I try to use templates in my functions but I can't seem to make them work. I defined my function in a file called ddc.hpp #ifndef __DIGITAL_DOWN_CONVERTER_H__ #define __DIGITAL_DOWN_CONVERTER_H__ namespace ddc { …
mr_hyde
  • 505
  • 1
  • 6
  • 11
0
votes
1 answer

Trouble with a namespace in a header file, "undefined reference to" error?

I'm getting the following errors due to the namespace cpl? I included Wavepacket.cpp and Vector.hpp below. obj\Debug\wavepacket.o||In function `Z10initializev':| wavepacket.cpp|79|undefined reference to…
pandoragami
  • 5,387
  • 15
  • 68
  • 116
0
votes
1 answer

undefined reference to vtable after the creation of a class object

I have the following two classes: class Grill { public: virtual ~Grill(); virtual std::string get_model() const{return _model;}; virtual void set_price(float p){_price=p;}; virtual float get_price() const {return _price;}; virtual Grill*…
Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
0
votes
0 answers

Building Boost 1.53.0 Boost Log 2.0r862 on OSX 10.8.3

I am working at building Boost 1.53.0 with Boost Log 2.0r862 on Mac OSX 10.8.2 and installed it to a fake root to keep the /usr/lib* and /opt/lib* clean. I built and installed Boost with./bootstrap --prefix=/path/to/myfakerootdirand installed the…
0
votes
0 answers

C++ multiple undefined reference error MinGW

I have add graphics.h and winbgim.h libraries, and also libbgi.a to MinGW. They can all be found here. The archive has folders that indicate the directory where they should be placed under /MinGW. I have also added -lbgi -lgdi32 -lcomdlg32 -luuid…
Mihai Bujanca
  • 4,089
  • 10
  • 43
  • 84
0
votes
1 answer

undefined reference to symbol even when nm indicates that this symbol is present in the shared library 2

I found same question here but the answer doesn't help me. I'm writing test app to use nglib library. But when I try to compile it I get undefined references: $ g++ test1.cpp -L. -lnglib test1.cpp: In function ‘int…
tom
  • 1,520
  • 1
  • 12
  • 26
0
votes
1 answer

Undefined reference to boost::thread in Qt

I'm trying to create a boost::thread application in Qt. Here is my code: #include #include "boost/thread.hpp" #include "boost/bind.hpp" using namespace std; class A { public: void tf() { for (int i = 0; i < 100; ++i) { …
spiralfuzet
  • 75
  • 10
0
votes
1 answer

Undefined reference errors in Qt application

I have a library and example application, driven by CMake. So, there is a class, which I use in library: sourceeditor.h #ifndef SOURCEEDITOR_H #define SOURCEEDITOR_H #include #include "novile_export.h" namespace Novile { class…
0
votes
2 answers

What am I missing? Undefined reference

I have been programming for 7 hours by now and I really can't see the problem due to exhaustion. I need some extra eyes. Why this code doesn't compile??? bool readFromFile(const char*, Graph[5]); bool writeToFile(Graph[5]); int main(int argc, char*…
Varaquilex
  • 3,447
  • 7
  • 40
  • 60
0
votes
0 answers

Undefined reference to 'AbstractClass::getInfo'

I have AbstractClass and virtual int getInfo() = 0; plus static int info; And I have class ConcreteClass with int ConcreteClass::getInfo() { return info; } But I get errors Undefined reference to 'AbstractClass::getInfo' and collect2:error:ld…
Admiral Land
  • 2,304
  • 7
  • 43
  • 81
0
votes
1 answer

Why undefiner reference?

In my test.cpp I have: #include #include "first.h" using namespace std; int main () { auto dliste = d::data_preparation::prepare_d(100); cout << "Hello World!\n"; return 0; } In my first.h I have: namespace d { namespace…
Roman
  • 124,451
  • 167
  • 349
  • 456
0
votes
1 answer

C++ Class expression parameter incorrect definition

I'm learning C++ and currently experiencing weird problem with Class template. This is my header file: #ifndef VECTOR_H #define VECTOR_H #include #include using namespace std; template class Vector { public: …
Ricardo Simmus
  • 334
  • 4
  • 19