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

Undefined reference to vkCreateInstance

FINAL EDIT: This is compiler/linker bug with TDM_GCC. See answer. EDIT: This is not a duplicate as far as I can tell. The problem appears to be a simple noob error, but this is not the case. I have linked to the correct Vulkan library "vulkan-1.lib"…
SeanRamey
  • 665
  • 7
  • 19
4
votes
1 answer

How to link curses.h in Cmake?

I know that maybe this is a silly question but I can't see through it, I searched for other answers here, that are pretty close to mine, but, still, I didn't understand how to do it. The problem is that I can't compile a 'C' program that uses…
Aster
  • 143
  • 2
  • 11
4
votes
1 answer

Undefined references in GSL

I'm trying to link gsl in a small c program. #include "stdlib.h" #include "stdio.h" #include "gsl/gsl_block_float.h" #include "gsl/gsl_matrix_float.h" int main(void) { gsl_matrix_float* m = gsl_matrix_float_alloc(2, 2); …
user4468022
4
votes
1 answer

cython module raises ImportError even though I'm linking in the necessary static libs

My cython module builds fine, but when I try to import it I get the following error: ImportError: ./pyflite.so: undefined symbol: basic_ff_register here's my setup.py. from distutils.core import setup from distutils.extension import Extension from…
ckot
  • 819
  • 2
  • 10
  • 23
4
votes
1 answer

Handling symbol lookup errors at runtime using C

Suppose I have a dynamic library that exports three functions: void lib_function(void); void lib_extra_function(void); int lib_runtime_version(int v); And lib_extra_function was added in version 2 of the library. If an application that uses…
4
votes
1 answer

Can't link GLFW3: undefined references

I realize something similar has been asked before (glfw3 compiling undefined references), but I still can't get it to work unfortunately. Any help is welcome! Below is the compiler output when running make: g++ -std=c++11 -Wall -Wextra -Werror…
smootherstep
  • 157
  • 3
  • 10
4
votes
2 answers

Undefined references only using MinGW GCC

After compiling codes in Ubuntu 12.04.3 for a while, I decided to give coding in Windows a go and installed MinGW. After the installation I set my path variables and the gcc seemed to work. However, some codes(especially those including multiple…
Vesnog
  • 773
  • 2
  • 16
  • 33
4
votes
4 answers

C++ linker errors, Undefined references to Items that should be referenced from a Share Object

I am building a library, called physgameengine, to aid in building games. This game library links against several libraries, including: Ogre3d, Bullet Physics and SDL, which are in the library files libOgreMain-1.6.5.so, libBulletCollision.a,…
Sqeaky
  • 1,876
  • 3
  • 21
  • 40
4
votes
1 answer

Undefined Reference for Vector

I am getting an undefined reference while using vectors. Here is the error: /tmp/ccYnTr05.o: In function `TourManager::addCity(City)': tsp.cpp:(.text._ZN11TourManager7addCityE4City[TourManager::addCity(City)]+0x1c): undefined reference to…
freecrap
  • 41
  • 1
  • 2
4
votes
1 answer

How can I use a makefile for D?

I have written complicated C and C++ makefiles in the past. However, I cannot seem to get my D makefile to work. It throws over a thousand lines of "undefined reference" errors, which look as if Phobos is failing to be linked. How can I fix that? I…
Demi
  • 3,535
  • 5
  • 29
  • 45
4
votes
1 answer

Compiler cannot find required SSL libraries - undefined reference to

I am trying to compile a C program which depends on some SSL libraries. When I try to compile I get the following error: michael@michael-VirtualBox:~/$ cc -lssl -lcrypto iot.o tun2iot.o -o tun2iot iot.o: In function…
TomSelleck
  • 6,706
  • 22
  • 82
  • 151
4
votes
2 answers

Cross-compiling OpenGL / glew on linux for windows

I'm trying to cross-compile a small test opengl/glew program and I get linker errors from undefined references. $ /usr/bin/i486-mingw32-g++ -I/usr/i486-mingw32/include -L/usr/i486-mingw32/lib/ -lglfw -lglew32 -lopengl32…
shiona
  • 539
  • 5
  • 8
4
votes
2 answers

Why I failed to compile a sctp program in Linux?

First I install sctp on Ubuntu 12.04 sudo apt-get install libsctp-dev lksctp-tools Then in my .c file,I include : #include < netinet/in.h > #include < netinet/sctp.h > #include < sys/socket.h > #include < stdlib.h > #include < unistd.h…
huaxz1986
  • 307
  • 5
  • 10
4
votes
1 answer

How to solve "undefined reference to function" error?

I have to build a library for a school project and use that library in a small aplication. Now, I have made the XPM_lib.h and XPM_lib.c files and also my test.c file. But when I try to compile my test.c file I get an "undefined reference to…
user1550876
  • 109
  • 1
  • 1
  • 10
4
votes
2 answers

C++11, enum class, undefined reference with g++, works with clang++

I used the new C++11 "enum class" type and observed a "undefined reference" problem when using g++. This probleme does not happen with clang++. I do not know if I am doing something wrong or if it is a g++ bug. To reproduce the problem here is the…
Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70