0

I am currently working on a game engine with SDL, openGL and C++. I'm using Visual Studio 2017. So far I've been writing code in the SDL main and had no issues whatsoever. Had my window opening and text showing up but a few days ago I added my first class and keep getting an error whenever I try to call a function:

Unable to start program (path/Program.exe) The system cannot find the file specified. In the error list I get this message -> State Error LNK2019: unresolved external symbol "public: void __thiscall Graphics::RenderMesh(void)" (?RenderMesh@Graphics@@QAEXXZ) referenced in function _SDL_main

the name of my function is RenderMesh and all it does it print "Rendering" with a cout. It has no problem with my object, fust the function calls. In the class heather the function declaration is underlined as a warning saying: function definition for RenderMesh not found. But it does exist in the cpp and the declaration is public. I don't understand why it would not detect it? I thought it could be a problem with compiling but then again it has no problems accessing a variable from a class it's specifically the functions.This is how I call my function:

int main(int argc, char *argv[])
{
    Graphics g;
    g.RenderMesh();
}

Also tried this:

Graphics *g = nullptr;
int main(int argc, char *argv[])
{
    g = new Graphics();
    g->RenderMesh();
}

I tried creating it automatically with the shortcut for Visual Studio but every time I do that the IDE freezes and I have to force close it through the task manager. Tried rebuilding, Linking my external libraries again and even started over on a different project, no change. Does anyone know what is the cause for this and how to fix it?

  • at a guess your definition of `RenderMesh` is as a global function rather than a member of `Graphics` but it's difficult to tell without a [mcve] – Alan Birtles Aug 07 '18 at 08:58
  • Thanks for all the help, I just realized I've forgotten to add the class selector :: on the function in my cpp. Thanks for the helpful comments and links, I managed to learn more about compiling and linker errors. – Aleksandra Petkova Aug 07 '18 at 09:35

0 Answers0