LNK2019: unresolved external symbol

Sam of Simple Samples 5,516 Reputation points
2021-09-20T21:53:29.08+00:00

I am currently still using VS 2017.

It has been man years since I have created a native DLL and now when I try to I was getting a linker error I cannot figure out. So I tried to follow the instructions in Walkthrough: Create and use your own Dynamic Link Library (C++) and I am getting the same problems. The following are the linker errors from the walkthrough.

1>MathClient.obj : error LNK2019: unresolved external symbol __imp__fibonacci_init referenced in function _main  
1>MathClient.obj : error LNK2019: unresolved external symbol __imp__fibonacci_next referenced in function _main  
1>MathClient.obj : error LNK2019: unresolved external symbol __imp__fibonacci_current referenced in function _main  
1>MathClient.obj : error LNK2019: unresolved external symbol __imp__fibonacci_index referenced in function _main  
1>G:\Documents\Samples\Microsoft\Walkthroughs\MathClient\Debug\MathClient.exe : fatal error LNK1120: 4 unresolved externals  

So let me back up a bit. For the header MathLibrary.h the following works:

#include "..\..\MathLibrary\MathLibrary\MathLibrary.h"  

However when I cut the path out and put that path in the Additional Include Directories it does not find the #include. I had the same problem with my initial project of a DLL and a console driver for executing the DLL.

I have followed the instructions in the walkthrough and added the MathLibrary.lib to the Additional Dependencies and the path for the library to the Additional Library Directories. When I use that path for dumpbin it shows the following symbols.

_fibonacci_current
_fibonacci_index
_fibonacci_init
_fibonacci_next

The following is the project properties for the DLL.

133783-t.jpg

The following is the Configuration Manager for it.

133746-t.jpg

Can anyone explain why I am getting the unresolved external symbols? If the malfunction is me then I sure do not see it. What can I do to diagnose it?

My system is due for a major rebuild. I should go for VS 2022 and perhaps I will give up on this problem until I do.

I have put my projects into GitHub.

https://github.com/SimpleSamples/MathLibrary
https://github.com/SimpleSamples/MathClient

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,473 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,592 questions
{count} votes

Accepted answer
  1. RLWA32 41,831 Reputation points
    2021-09-21T01:53:11.667+00:00

    You had a bad fully qualified path set in the x64 linker property for Additional Library Directories.

    Change the path to -

    133757-samlinker.png


1 additional answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor
    2021-09-21T06:02:04.573+00:00

    I have build the both two projects successfully except modifying the MathClient Additional Include Directories, Additional Library Directories, Post-Build Event because my folder name is MathLibrary-master.
    133871-image.png