Quantcast
Channel: What is an undefined reference/unresolved external symbol error and how do I fix it? - Stack Overflow
Browsing latest articles
Browse All 40 View Live

Answer by n. m. could be an AI for What is an undefined reference/unresolved...

I am building a shared/dynamic library. It works on Linux and *BSD, but on Mac OS X the exact same compile and link commands produce unresolved reference errors. What gives?Mac OS X is very different...

View Article



Answer by n. m. could be an AI for What is an undefined reference/unresolved...

Using Visual Studio Code with the Code Runner extension and multiple .c or .cpp filesCode Runner as shipped only works with compiled programs that have a single source file. It is not designed for use...

View Article

Answer by AliceTheCat for What is an undefined reference/unresolved external...

Some typo errors to consider: (happened to me as a beginner a lot)If you are using a class: check if you have not forgetton "classname::" before the function name inside your cpp file where you define...

View Article

Answer by n. m. could be an AI for What is an undefined reference/unresolved...

When you are using a wrong compiler to build your programIf you are using gcc or clang compiler suites, you should use the right compiler driver according to the language you are using. Compile and...

View Article

Answer by ma1169 for What is an undefined reference/unresolved external...

In my case, The syntax was correct, yet I had that error when a class calls a second class within the same DLL. the CPP file of the second class had the wrong Properties->Item Type inside visual...

View Article


Answer by Zig Razor for What is an undefined reference/unresolved external...

An “Undefined Reference” error occurs when we have a reference to object name (class, function, variable, etc.) in our program and the linker cannot find its definition when it tries to search for it...

View Article

Answer by A. P. Damien for What is an undefined reference/unresolved external...

My example:header fileclass GameCharacter : public GamePart{ private: static vector<GameCharacter*> characterList;...}.cpp file:vector<GameCharacter*> characterList;This produced an...

View Article

Answer by the-wastelander for What is an undefined reference/unresolved...

This issue occurred for me by declaring the prototype of a function in a header file:int createBackground(VertexArray rVA, IntRect arena);But then defining the function elsewhere using a reference with...

View Article


Answer by Mike Kinghan for What is an undefined reference/unresolved external...

Functions or class-methods are defined in source files with the inline specifier.An example:-main.cpp#include "gum.h"#include "foo.h"int main(){ gum(); foo f; f.bar(); return 0;}foo.h (1)#pragma...

View Article


Answer by Matthieu Brucher for What is an undefined reference/unresolved...

Different architecturesYou may see a message like:library machine type 'x64' conflicts with target machine type 'X86'In that case, it means that the available symbols are for a different architecture...

View Article

Answer by ead for What is an undefined reference/unresolved external symbol...

When linking against shared libraries, make sure that the used symbols are not hidden.The default behavior of gcc is that all symbols are visible. However, when the translation units are built with...

View Article

Answer by Stypox for What is an undefined reference/unresolved external...

Even though this is a pretty old questions with multiple accepted answers, I'd like to share how to resolve an obscure"undefined reference to" error. Different versions of librariesI was using an alias...

View Article

Answer by Andreas H. for What is an undefined reference/unresolved external...

Missing "extern" in const variable declarations/definitions (C++ only)For people coming from C it might be a surprise that in C++ global constvariables have internal (or static) linkage. In C this was...

View Article


Answer by Mike Kinghan for What is an undefined reference/unresolved external...

Your linkage consumes libraries before the object files that refer to themYou are trying to compile and link your program with the GCC toolchain.Your linkage specifies all of the necessary libraries...

View Article

Answer by fafaro for What is an undefined reference/unresolved external...

When your include paths are differentLinker errors can happen when a header file and its associated shared library (.lib file) go out of sync. Let me explain.How do linkers work? The linker matches a...

View Article


Answer by Niall for What is an undefined reference/unresolved external symbol...

Inconsistent UNICODE definitionsA Windows UNICODE build is built with TCHAR etc. being defined as wchar_t etc. When not building with UNICODE defined as build with TCHAR defined as char etc. These...

View Article

Answer by Niall for What is an undefined reference/unresolved external symbol...

Befriending templates...Given the code snippet of a template type with a friend operator (or function);template <typename T>class Foo { friend std::ostream& operator<<...

View Article


Answer by Niall for What is an undefined reference/unresolved external symbol...

Clean and rebuildA "clean" of the build can remove the "dead wood" that may be left lying around from previous builds, failed builds, incomplete builds and other build system related build issues.In...

View Article

Answer by Plankalkül for What is an undefined reference/unresolved external...

Since people seem to be directed to this question when it comes to linker errors I am going to add this here.One possible reason for linker errors with GCC 5.2.0 is that a new libstdc++ library ABI is...

View Article

Answer by user4272649 for What is an undefined reference/unresolved external...

Suppose you have a big project written in c++ which has a thousand of .cpp files and a thousand of .h files.And let's says the project also depends on ten static libraries. Let's says we are on Windows...

View Article

Answer by Niall for What is an undefined reference/unresolved external symbol...

Use the linker to help diagnose the errorMost modern linkers include a verbose option that prints out to varying degrees;Link invocation (command line),Data on what libraries are included in the link...

View Article


Answer by Nima Soroush for What is an undefined reference/unresolved external...

This is one of most confusing error messages that every VC++ programmers have seen time and time again. Let’s make things clarity first.A. What is symbol?In short, a symbol is a name. It can be a...

View Article


Answer by JDiMatteo for What is an undefined reference/unresolved external...

A wrapper around GNU ld that doesn't support linker scriptsSome .so files are actually GNU ld linker scripts, e.g. libtbb.so file is an ASCII text file with this contents:INPUT (libtbb.so.2)Some more...

View Article

Answer by Malvineous for What is an undefined reference/unresolved external...

Visual Studio NuGet package needs to be updated for new toolset versionI just had this problem trying to link libpng with Visual Studio 2013. The problem is that the package file only had libraries for...

View Article

Answer by brettwhiteman for What is an undefined reference/unresolved...

A bug in the compiler/IDEI recently had this problem, and it turned out it was a bug in Visual Studio Express 2013. I had to remove a source file from the project and re-add it to overcome the...

View Article


Answer by Kastaneda for What is an undefined reference/unresolved external...

what is an "undefined reference/unresolved external symbol"I'll try to explain what is an "undefined reference/unresolved external symbol".note: i use g++ and Linux and all examples is for it For...

View Article

Answer by Niall for What is an undefined reference/unresolved external symbol...

Microsoft offers a #pragma to reference the correct library at link time;#pragma comment(lib, "libname.lib")In addition to the library path including the directory of the library, this should be the...

View Article

Answer by Svalorzen for What is an undefined reference/unresolved external...

The order in which interdependent linked libraries are specified is wrong.The order in which libraries are linked DOES matter if the libraries depend on each other. In general, if library A depends on...

View Article

Answer by Dula for What is an undefined reference/unresolved external symbol...

Also if you're using 3rd party libraries make sure you have the correct 32/64 bit binaries

View Article



Answer by kiriloff for What is an undefined reference/unresolved external...

Linked .lib file is associated to a .dllI had the same issue. Say i have projects MyProject and TestProject. I had effectively linked the lib file for MyProject to the TestProject. However, this lib...

View Article

Answer by πάνταῥεῖ for What is an undefined reference/unresolved external...

undefined reference to WinMain@16 or similar 'unusual'main() entry point reference (especially for visual-studio).You may have missed to choose the right project type with your actual IDE. The IDE may...

View Article

Answer by sgryzko for What is an undefined reference/unresolved external...

If all else fails, recompile.I was recently able to get rid of an unresolved external error in Visual Studio 2012 just by recompiling the offending file. When I re-built, the error went away. This...

View Article

Answer by Luchian Grigore for What is an undefined reference/unresolved...

Incorrectly importing/exporting methods/classes across modules/dll (compiler specific).MSVS requires you to specify which symbols to export and import using __declspec(dllexport) and...

View Article


Answer by Luchian Grigore for What is an undefined reference/unresolved...

Symbols were defined in a C program and used in C++ code.The function (or variable) void foo() was defined in a C program and you attempt to use it in a C++ program:void foo();int main(){ foo();}The...

View Article

Answer by Luchian Grigore for What is an undefined reference/unresolved...

Template implementations not visible.Unspecialized templates must have their definitions visible to all translation units that use them. That means you can't separate the definition of a templateto an...

View Article

Answer by Luchian Grigore for What is an undefined reference/unresolved...

Class members:A pure virtual destructor needs an implementation.Declaring a destructor pure still requires you to define it (unlike a regular function):struct X{ virtual ~X() = 0;};struct Y : X{ ~Y()...

View Article


Answer by Luchian Grigore for What is an undefined reference/unresolved...

Declared but did not define a variable or function.A typical variable declaration isextern int x;As this is only a declaration, a single definition is needed. A corresponding definition would be:int...

View Article


Answer by Luchian Grigore for What is an undefined reference/unresolved...

Failure to link against appropriate libraries/object files or compile implementation filesCommonly, each translation unit will generate an object file that contains the definitions of the symbols...

View Article

Answer by Luchian Grigore for What is an undefined reference/unresolved...

Say you have the following code:// a.cppint get() { return 0; }// b.cppint get(); // usually, one doesn't write this directly, but gets these // declarations from included header filesint x =...

View Article

What is an undefined reference/unresolved external symbol error and how do I...

What are undefined reference/unresolved external symbol errors? What are common causes, and how do I fix and prevent these errors?

View Article
Browsing latest articles
Browse All 40 View Live




Latest Images