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

Implementing CURL with Visual Studio 2010

I am trying to compile a program that uses Curl in Visual Studio 2010 on Windows Vista x64. I downloaded the latest version of Curl 7.23.1 from the official website and unzipped it to C:Program Files. From there, I opened the VCProject file in the…
3
votes
6 answers

beginner c++: virtual functions in a base class

I'm writing some code where I defined the following base class. class Chorus{ public: //Destructor virtual ~Chorus(); //callback function virtual int callback( void *outputBuffer, void *notUsed, unsigned int …
Rich
  • 2,805
  • 8
  • 42
  • 53
3
votes
1 answer

Unresolved external when using templates

I'm mixing operator redefinition with template classes and reached to the following assigment: j = end - begin; in my main function, where variable types are as follows: ptrdiff_t j; util::BaseArrayIterator begin, end; Begin and end have…
Tetelu
  • 31
  • 2
3
votes
0 answers

Embedding lua into c++ but getting unresolved externals : floor, freopen & strcoll

I'm embedding lua into a c++ vs2019 solution and it results in linking errors to basic c libraries ( __imp_freopen, __imp_floor and __imp_strcoll ). lua compiles as a static c library in it's own project and is linked to the main project, but when…
Martian
  • 108
  • 6
3
votes
1 answer

How do I get Visual Studio to compile my application with OpenCV support?

I need to compie and run a windows program that uses OpenCV. For that, I've downloaded and installed MS Visual Studio 2010. I confirmed that I can compile & run a Hello World terminal application. Now, I've installed OpenCV and set up the Compiler…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
3
votes
1 answer

C++ Virtual Destructor with Unresolved externals

I have two classes.. template class Node { protected: Node() = default; virtual ~Node() = 0; Node(const T& data) noexcept; Node(const Node & copy) noexcept; Node(Node && copy) noexcept; Node &…
Jared
  • 2,029
  • 5
  • 20
  • 39
3
votes
1 answer

Unresolved external symbols using ffmpeg

I just downloaded the dev package for ffmpeg and was setting up headers and libraries for use. I'm using Visual C++ 2013 and I added the path of the ffmpeg header files and libs. I linked to every single lib file in the ffmpeg lib folder and…
3
votes
4 answers

unresolved external symbol _WinMainCRTStartup

I'm trying to assemble a simple "Hello world" application with Masm32. It assembles fine but when I try to link it, the linker says LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup prog1.exe : fatal error LNK1120: 1 unresolved…
Tihomir Mitkov
  • 846
  • 1
  • 11
  • 20
3
votes
2 answers

Strange error: unresolved symbol when compiling with PHP7 on Windows

I have a strange problem: I have a project, which uses PHP7 (php7ts.lib) in it. PHP7 is compiled on my own with VS 2015: --enable-mbstring=static --with-gd=static --with-iconv=static --enable-soap --enable-sockets --disable-ipv6 --with-dom…
devopsfun
  • 1,368
  • 2
  • 15
  • 37
3
votes
4 answers

Trouble with 'extern' Keyword

I have a set of global variables and a method in a cpp file. int a; int b; int c; void DoStuff() { } in the header file I have declared them explicitly with the extern keyword. My problem is when I include the header file in another C++ file, I…
Izza
  • 2,389
  • 8
  • 38
  • 60
3
votes
1 answer

C++ LNK2019 unresolved external symbol stdlib

I have a program that requires atol() in one of its functions. So I included stdlib.h but it doesn't seem to see it. EDIT: I'm aware to use it, I should include stdlib.h. I did that but I'm still getting this error. The function: void intstr(…
3
votes
2 answers

Unresolved Externals using Cmake and Visual Studio 2013

I've been having problems with cmake and Visual Studio 2013 with SFML. When I try and compile my program, I'm getting unresolved externals for everything that uses SFML. I've had problems with this on multiple machines, and also with some other…
AdmiralJonB
  • 2,038
  • 3
  • 23
  • 27
3
votes
2 answers

Link OpenCV library to Qt

I'm trying to create an interface application where I need to use OpenCV to display two videos in one window. I have tried Qt but I have some errors like "unresolved external symbol". I guess that I haven't well linked Qt to OpenCV library. This is…
Dutchman
  • 41
  • 6
3
votes
2 answers

Unresolved external symbol in libgcrypt.lib

What I have to do if i found Unresolved external symbol in .lib(library) file. If I found unresolved external symbol in .c or .cpp I can fix it. But when i found Unresolved external symbol in .lib(library) file how can i solve this? In my case i…
Myanju
  • 1,135
  • 1
  • 11
  • 23
3
votes
1 answer

Unresolved external symbol displayed as an error while /force:unresolved is used

Is there a way to change the severity of the LNK2001 log (let say from error to warning), or even avoid this log, when /force:unresolved flag is used at link time ? Basically, I want to force the generation of a dll (with a undefined symbol, let…