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

crc32() missing when building libzip on OSX 10.9

I've downloaded the latest release of libzip and am currently trying to build it on OSX and failing: Linking C shared library libzip.dylib Undefined symbols for architecture x86_64: "_crc32", referenced from: __zip_filerange_crc in…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
6
votes
3 answers

Houston, we have an undefined reference

MEGAEDIT 3000 I have discovered the cause of undefined references. I checked my .o files for symbols, and they were just missing. Just weren't there. For no apparent reason. I have checked the source of the compromiting .o file, but everything…
matuzalem
  • 367
  • 1
  • 2
  • 14
6
votes
1 answer

Linking D library to C++ code

Recently I learned the beautiful language D, which is so more plastic and helps yourself writing stable fast programs. But its not popular... because few code written on D and so more on C and C++. Therefore after I read the book of Andrei…
6
votes
1 answer

Google test undefined reference using SetUpTestCase static variable

I am writing a testcase that will have a SetUpTestCase() method that will allocate a shared resource although I am receiving undefined reference linker errors. class ParsingEventsTest: public ::testing::Test { protected: static xml…
Patryk
  • 22,602
  • 44
  • 128
  • 244
6
votes
4 answers

.dll Plugin that uses functions defined in the main executable

I have a Main executable that loads .dll/.so Plugins, which works just fine in Linux but on windows(Visual Studio 2012), it fails with undefined reference errors. The plugin uses functions like session->SendLine("bla") which are defined in the Main…
Naga
  • 118
  • 10
6
votes
2 answers

C++ undefined reference to template class method

I always get undefined reference to `Graph::InsertVertex(std::string)' if I compile my project! Any hints why he cant resolve this reference? (all Files are in the netbeans project folder) // main.cpp #include #include #include…
leon22
  • 5,280
  • 19
  • 62
  • 100
6
votes
3 answers

Qt and C++ - undefined reference to slot

I have a build error with a slot in Qt. I have an class which has a public slot: void doSomething(); In constructor of this class i do: this->connect( ui->textFrom, SIGNAL(returnPressed()), this, SLOT(doSomething()) ); I have…
Max Frai
  • 61,946
  • 78
  • 197
  • 306
6
votes
1 answer

with -lpthread, g++ compiler error, "undefined reference to " semaphore calls such as `sem_open'

I am new to posix thread library, and I tried to compile a sample code from a tutorial with: g++ -lpthread agreement.cpp -o agreement however I was not able to compile the code and got the following error message: a3q2.cpp:(.text+0x7e): undefined…
Mike
  • 425
  • 2
  • 6
  • 8
5
votes
1 answer

Linker Error: Undefined Reference to `vtable for square`. Code includes virtual functions

I've checked the most common undefined reference to vtable question on here, and while that gave me a better understanding of what is going on, I still wasn't able to gather enough information to figure out why I'm having this error. I have a…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
5
votes
1 answer

Undefined reference on very simple program

Once I installed Ubuntu 11.10, strange error appears. I want to use GD with my C program, so I installed package "libgd2-xpm-dev". Everything was installed - files gd.h and libgd.a are in "/usr/include" and in "/usr/lib". So, I've tried to compile…
lanus
  • 53
  • 1
  • 1
  • 4
5
votes
2 answers

Multiple definition [...] first define here

I'm writing a H264 parser (no OO), but I'm trying to use some modules to organize better the things. I'm having this problems: `CMakeFiles/server.dir/mainclass.cpp.o:(.bss+0x0): multiple definition of `I_Macroblock_Modes' …
Pedro Dusso
  • 2,100
  • 9
  • 34
  • 64
5
votes
1 answer

undefined reference to `__ubsan_handle_nonnull_arg'

I have been working on the problem set speller for the last days and so far this is what I have. Unfortunately, it does not compile and I am a bit lost. I would be really grateful if somebody can help me out and tell me, what I am doing wrong. //…
viet
  • 61
  • 1
  • 2
5
votes
1 answer

How the assembly file is generated from the perl script in OpenSSL

In the opensource code of OpenSSL(version 1.1.0e) I saw that some of the function definition is generated by the perl files present inside the folders. In the build.info file present in each folders inside the crypto, they have written some lines to…
TreesaL
  • 79
  • 6
5
votes
1 answer

Getting undefined reference to std::thread::_M_start_thread

I'm building an app that uses a 3rd party lib (Box2D-MT) which I build from sources. When linking, I get this undefined reference…
Bogdan Ionitza
  • 331
  • 1
  • 6
  • 14
5
votes
0 answers

undefined reference to `__gnu_Unwind_Find_exidx'

My NDK Project Build success only when APP_ABI := armeabi armeabi-v7a when I enabled arm64-v8a in Application.mk for example: APP_ABI := armeabi armeabi-v7a arm64-v8a The project will build failed and show the error undefined reference to…
L.Ning
  • 51
  • 1