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

Undefined reference to sf::

I wanted to make gui apps in c++ and found SFML to be a good choice. Fortunately i am on linux so SFML(2.4) was already installed on my system. So i started searching for some tutorials and found one that makes a simple window. But when i run the…
Sawaira Khan
  • 37
  • 1
  • 1
  • 4
3
votes
2 answers

"Undefined reference" error in Qt Creator

I'm trying to import some working Visual C++ code into Qt Creator and I'm having some compilation error I can't explain. This is my code: // TabSprite.h #include namespace appetizer { class TabSprite : public GraphicsItem…
laurent
  • 88,262
  • 77
  • 290
  • 428
3
votes
2 answers

Mixing C and C++... undefined reference to function

In a C++ project, I'm trying to call this function, which is defined in C: int CyBtldr_RunAction(CyBtldr_Action action, const char* file, const uint8_t* securityKey, uint8_t appId, CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate*…
kjgregory
  • 656
  • 2
  • 12
  • 23
3
votes
1 answer

Undefined symbol using template

I am getting a linker error building this code: Exclude.h file class IsExclude { public: template bool operator()(const T* par); virtual ~IsExclude() = 0; }; IsExclude::~IsExclude() {} class IsExcludeA :…
Alessandro Teruzzi
  • 3,918
  • 1
  • 27
  • 41
3
votes
1 answer

Can't link a simple "hellow world" with Simd Library

I'm trying to compile a simple code wich calls one function of Simd Library: // simd.c #include #include "Simd/SimdLib.h" int main(void) { uint8_t buf1[720*576]; uint8_t buf2[900*720]; SimdResizeBilinear(buf1, 720, 576,…
MikeZ
  • 33
  • 6
3
votes
3 answers

Error while compiling libpqxx code example?

I am trying to compile libpqxx code example: #include #include int main(int, char *argv[]) { pqxx::connection c("dbname=company user=accounting"); pqxx::work txn(c); pqxx::result r = txn.exec( "SELECT id " …
user2856064
  • 541
  • 1
  • 8
  • 25
3
votes
1 answer

Undefined reference to template members

I'm new to C++, and preparing a homework by using NetBeans IDE on Ubuntu 10.04. I use g++ as a C++ compiler. The error message: build/Debug/GNU-Linux-x86/Maze.o: In function `Maze': Maze/Maze.cpp:14: undefined reference to…
Bnymn
  • 147
  • 1
  • 2
  • 8
3
votes
0 answers

nested enum vs constexpr static member variable

When the constexpr was introduced to C++ I started to write my compile time constants as constexpr static member variables instead of using the enum hack. So I know about the subtle difference that you cannot take the address of a constant defined…
mic
  • 821
  • 6
  • 18
3
votes
0 answers

linux based android repo build boringssl libcrypto-host undefined reference to `sha512_block_data_order'

while compiling android firmware on linux Ubuntu 16.04 x86-64 host uname -sm Linux x86_64 following error occur in boringssl module: out/host/linux-x86/obj/SHARED_LIBRARIES/libcrypto-host_intermediates/src/crypto/sha/sha512.o: In function…
Oleg Kokorin
  • 2,288
  • 2
  • 16
  • 28
3
votes
2 answers

c++ " undefined reference to 'Foo::Foo(std::string)' "

I'm not too familiar with c++ and how instantiating objects work, so this is probably a very simple thing to solve. When I compile with g++ I get the error " undefined reference to 'Foo::Foo(std::string)' ". I want to create an instance of the…
Aaron
  • 1,693
  • 4
  • 26
  • 40
3
votes
1 answer

no reference to pthread_mutex_lock with -lpthread compiled

I am compiling a program that contains mutex semaphores from the pthread library but when i compile using the -lpthread flag I am getting an undefined reference error. gcc -lpthread prodcon.c /tmp/ccESOlOn.o: In function…
aastorms
  • 45
  • 1
  • 1
  • 4
3
votes
4 answers

Getting undefined references when linking against a static library

I made a static library with GCC. Building of the library was OK. When I use it the linker throws undefined reference errors on some functions. But nm says the functions are defined and exported in the static library (marked with T). I know about…
Calmarius
  • 18,570
  • 18
  • 110
  • 157
3
votes
2 answers

OpenCV C++/C compilation error: undefined reference to `cv::fastFree(void*)'

I am trying to have a C program call a function in a C++ file that uses OpenCV. I can get the C file to call a basic integer function in a C++ file and return a result, but whenever I try to add some OpenCV code to the C++ file, I get compilation…
3
votes
1 answer

Why crc32 value require -lz

I am generating a crc32 value by using crc32(initial_crc_value,data,data_length); . if I am not using -lz in linker options, I am getting linker error as "undefined reference to crc32". I did not include any zlib.h. So, in which header file…
user4790894
  • 49
  • 1
  • 3
3
votes
1 answer

Undefined reference errors are coming when trying to compile a c++ project that uses SFML library

I am having some problem compiling a simple program in linux :- #include int main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!"); while (window.isOpen()) { sf::Event event; …
anonymous
  • 448
  • 1
  • 6
  • 25