adamstark/Gist

Unresolved Externals

LadyJuse opened this issue · 9 comments

Hello.

I am using Gist as part of a project and when I added Gist and some sample code to the project; I got the old LNK2019 error in Visual Studio 2017.

Just from using the constructor; I am getting:

  • LNK2019 unresolved external symbol "public: __cdecl Gist::Gist(int,int,enum WindowType)" (??0?$Gist@M@@qeaa@HHW4WindowType@@@z) referenced in function main
  • LNK2019 unresolved external symbol "public: __cdecl Gist::~Gist(void)" (??1?$Gist@M@@qeaa@XZ) referenced in function main

This is true in both my project, which I am intending to use FFTW and in an isolated solution which Kiss FFT is intended.

The FFTW is working fine on its own, and I believe that this issue has to do with the flagging for the dependencies.

Here is the basic code from the isolated solution:

#include "pch.h"
#include "src\Gist.h"
#include <iostream>

int main() {
	int frameSize = 512;
	int sampleRate = 44100;

	Gist<float> gist(frameSize, sampleRate);
}

Hi there, it looks as if you need to include the Gist.cpp files in your project - you have included the header file Gist.h, but the linker error seems to be because it can't find the implementation files. You need to include the whole src directory in your project. Let me know how you get on :)

Thank you! So I put #include "src\Gist.cpp" with the `#include "src\Gist.h", right?

Not quite - you need to add the Gist.cpp file to your project (this tells the compiler to compile that file). If you only include the header file and don't add the .cpp file to the project then the compiler knows the class/function declarations in the header file, but it doesn't have any access to the implementations.

Also, this extends to all the .cpp files in the Gist project. The easiest way to deal with this is to add the 'src' folder to your project in Visual Studio - everything you need is in that folder :)

Adam

I apologize for asking seemingly obvious questions, but this is sorta new to me; do I need a .dll file for this?

No problem :)

Not a .dll, no. It is just a question of having the right files in your project. You are using Visual Studio right? If you add the 'src' folder inside the Gist project into your project, then all those files will be added for compilation. Right now it seems you are only adding the header file and so the compiler has no access to the .cpp files (which contain the implementations of all the code you want to use).

Does that make sense? :)

I think so, however, I currently have all the Git files in the src folder in my project folder; so would that mean I have to add them so they are in the Solution Explorer?

I'm afraid I'm not knowledgeable enough about Visual Studio to advise you here (I'm on a mac 99% of the time). But in short, the compiler needs to know about the .cpp files and this normally involves adding them to your project in some way. :)

Okay, thanks for the help

No problem :)