Error LNK2019 unresolved external symbol "public: __thiscall display::display(void)" (??0display@@QAE@XZ) referenced in function "public: __thiscall field::field(void)" (??0field@@QAE@XZ) SnakeByteWin C:\Users\iptamas\source\repos\SnakeByteWin\SnakeByteWin\field.obj 1
Error LNK2019 unresolved external symbol "public: void __thiscall display::displayFullGame(struct HWND__ *,class field *,int)" (?displayFullGame@display@@QAEXPAUHWND__@@PAVfield@@H@Z) referenced in function "long __stdcall WindowProci(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProci@@YGJPAUHWND__@@IIJ@Z) SnakeByteWin C:\Users\iptamas\source\repos\SnakeByteWin\SnakeByteWin\windowproc.obj 1
Hi All,
This is the error I keep getting. I have a
field.h with the field class, a
display.h with the display class, and a
windowproc.h and .cpp with the windowproc function. I guess the windowproc cannot see the definition of the display class, but I don't know why.
field.h=========================================
#ifndef FIELD_H_INCLUDED
#define FIELD_H_INCLUDED
#include "defines.h"
#include "matrix.h"
#include "bites.h"
#include "snake.h"
#include "display.h"
class field {
int score;
int hiScore;
int level;
int nofBites;
int speed;
int scoreCounter;
bool isGameOn;
bites* bitesPr;
snake* snakePr;
matrix* matrixPr;
display* displayPr;
public:
field();
~field();
void initLevel();
void initGame();
int getScore();
void setScore(int);........ and so on....
display.h=========================================
#pragma once
#include"windowproc.h"
class field;
class display {
HBITMAP hBitmapWall;
HBITMAP hBitmapNoWall;
HBITMAP hBitmapBites;
HBITMAP hBitmapSnake;
HBITMAP hBitmapStartButton;
RECT scoreRect;
public:
display();
BOOL CALLBACK displayChildWindows(HWND hwnd, LPARAM lParam);
void displayFullGame(HWND hwnd, field*, int);
RECT getScoreRect();
HBITMAP getBitmapWall();
HBITMAP getBitmapNoWall();
HBITMAP getBitmapBites();
HBITMAP getBitmapSnake();
HBITMAP getBitmapStartButton();
};
windowproc.cpp===============================================
#include "field.h"
LRESULT CALLBACK WindowProci(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
LRESULT r = 0;
field* fg=(field*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch(uMsg){
case WM_NCCREATE: {
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)(((CREATESTRUCT*)lParam)->lpCreateParams));
r=DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
}
...... other case's ......
case WM_TIMER: {//========================= WM_TIMER message =====================
//display d;
if (!fg->getNofBites()) PostMessage(hwnd, STARTNEWLEVEL, 0, 0); // events of fullGame + display fullGame
fg->isSnakeAlive();
fg->moveSnake();
fg->decreaseScoreCounter();
if (fg->isBitesEaten()) {
fg->generatePositionBites();
fg->nofBitesDown();
fg->setScore(fg->getScore() + fg->getScoreCounter());
fg->setScoreCounter(SCORECOUNTER + fg->getLevel()*LEVELLER);
fg->getSnakePr()->setCounter(COUNTER);
fg->getDisplayPr()->displayFullGame(hwnd, fg, DISPLAYSCORE);
}
fg->getDisplayPr()->displayFullGame(hwnd, fg, DISPLAYBITES);
fg->getDisplayPr()->displayFullGame(hwnd, fg, DISPLAYSNAKE);
if (fg->getSnakePr()->getAlive()) PostMessage(hwnd, GAMEOVER, 0, 0);
break;
}// case WM_TIMER)
What I have tried:
My assumption is that 'include's are not correct. I tried almost all the variations, but when I managed to avoid all the 'double includes', I still got the same message.
I also tried to create the instance of the display class in the windowproc function, but it did not work either.
Any idea? Thank you.