Questions tagged [unresolved-external]

For questions about code that compiles but does not link due to unresolved external symbols. It is important that questions include the full linker command as well as the minimal program that references the name in question.

"Unresolved external symbol" is a linker error. It often means that some function has a declaration, but not a definition.

A common cause of this error is compiling code against a library's headers, but failing to link with that library's code: missing the library from the link command, or picking up a different version of the library.

There is a FAQ: What is an undefined reference/unresolved external symbol error and how do I fix it?. If your question lacks the full linker command, and shows no evidence of having read those answers, do not be surprised if you are redirected there.


How to write a good question

  • Create the simplest reproducible program to demonstrate the issue. A simple way to do this in C is to take the address of the symbol and use it:

    #include <pthread.h>
    
    int main()
    {
        int (*a)(pthread_t) = pthread_detach;
        return !a;
    }
    
  • Show the command used to link the program, and its output:

    gcc -std=c11 -fPIC unresolved-external.c -o unresolved-external
    
    /tmp/user/1432/ccI38tid.o: In function `main':
    unresolved-external.c:5: undefined reference to `pthread_detach'
    collect2: error: ld returned 1 exit status
    
537 questions
0
votes
2 answers

error LNK 2019 Unresolved externals Build error during compilation in c++

I keep getting this error when I try to compile my project in visual studio 2015 and I have tried countless alternatives but none seems to work. What I have tried so far: Made sure I am running the correct visual studio project (console…
0
votes
1 answer

Unresolved external symbol "protected static struct" error despite being defined in a .cpp file

This is my eventhandler.h #pragma once #include #include class EventHandler { public: EventHandler() { } ~EventHandler() { } static std::queue Events; }; I've searched a lot to try and solve…
0
votes
1 answer

A plethora of unresolved externals when compiling sample Cinder projects

This is the directory structure for Cinder externals that concerns the question. I don't have any issues with includes, I don't know why I have so many problem with the externals. +---lib | | +---msw | | +---x86 | | | +---debug | | …
0
votes
0 answers

Unresolved External Errors with Template Class .cpp Inclusion

first question ever, here goes: I've got a template class split into header and source file. At the bottom of the header file I'm including the source file and I'm using #ifndef/#define/#endif guards on the source file now. Many folks suggest to…
Dan White
  • 533
  • 1
  • 8
  • 18
0
votes
0 answers

unresolved external when overloading an operator

I have a simple C++ class as follows: class __declspec(dllexport) PrefData { public: PrefData(); int m_data_member; }; std::ostream& operator<<(std::ostream& os, const PrefData& obj); This results in an unresolved external error with…
Luca
  • 10,458
  • 24
  • 107
  • 234
0
votes
0 answers

Unresolved external symbol LNK2019 Qt Creator

I have probably seen all the topics discussing this issue but I still can't fix it #pragma once #include #include #include #include #include #include #include…
0
votes
1 answer

How to resolve an unresolved external symbol error with MSVCRTD.lib

I have a C++ Visual Studio DLL project that has a link error: MSVCRTD.lib(tncleanup.obj) : error LNK2019: unresolved external symbol __imp__InitializeSListHead@4 referenced in function "void __cdecl __scrt_initialize_type_info(void)"…
0
votes
1 answer

Unresolved Extern

I am using extern in my project for variables and functions so that i can share that with my other source files in future. How am i trying to use it? I had made a "Header file" for Declaration of Variables and functions by the name dec.h There is…
Nouman Tajik
  • 433
  • 1
  • 5
  • 18
0
votes
0 answers

Link 2019 error - unresolved external symbol

I tried reading this article, but I didn't really understand it to well: What is an undefined reference/unresolved external symbol error and how do I fix it? I copied this program straight from the book, and can't get it to work. I want to make…
0
votes
1 answer

DLIB On visual studio 2015 throws a unresolved external error

I'm trying to run the face detection example provided by dlib. I have set up my library directories and my include folders. I've included source.cpp in the project, and have added the files from the externals folder into it as well. When I run the…
0
votes
2 answers

unresolved extern symbol error, only works when define function in the header

everyone, my first post here, if my style annoys your please let me know I am looking to learn how to post here. I hope someone could help me with this LNK2019 Error I got two source files, battleship.cpp and tester.cpp, the main() function is…
petergx
  • 45
  • 6
0
votes
1 answer

Accessing a function from another file (C++, QT) Unresolved external

I've been beating my head against this for too long now, and have researched everything I cannot find what's wrong. I'm writing a GUI program in QT and have a few functions in some files external to the main program file, but within the project. The…
George G
  • 61
  • 1
  • 8
0
votes
2 answers

Dynamic Functionname - Cannot resolve extern symbol

I am trying to generate function names dynamically with preprocessor directives (add a optional prefix). The generation works and when gcc outputs me the code after the preprocessor (gcc -E), gcc tells me that the function has the right name. But…
Ferdinand Brunauer
  • 351
  • 1
  • 3
  • 15
0
votes
1 answer

pcl_visualizer.h - fatal error LNK1120: 1 unresolved externals

error LNK2001: unresolved external symbol "public: virtual void __cdecl pcl::visualization::PCLVisualizer::FPSCallback::Execute(class vtkObject *,unsigned long,void *)"…
0
votes
1 answer

Unresolved external symbol link error for exported class' static constants (some projects only)

I have a class in project Utils as follows: Maths.h class __declspec(dllexport) Maths { public: static const double c_epsilon; ... } Maths.cpp const double Maths::c_epsilon = DBL_EPSILON; I then have (many) other projects that use this class…
grae22
  • 104
  • 11