Hi, I'm new here.
I've got a problem with my project. I get the following link error in VS2008

main.obj : error LNK2019: unresolved external symbol "public: __thiscall PSystemManager::PSystemManager(struct HWND__ *)" (??0PSystemManager@@QAE@PAUHWND__@@@Z) referenced in function "public: virtual bool __thiscall MyApp::OnInit(void)" (?OnInit@MyApp@@UAE_NXZ)

main.cpp is for example this:

#include "./PSystemManager.h"
bool MyApp::OnInit(){
	PSystemManager* ps = new PSystemManager(pgui->getDrawArea());

PSystemManager is a class I made and has this constructor PSystemManager(HWND wind); which is defined in PSystemManager.cpp file(which includes PSystemManager.h)

They both include <windows.h> for HWND. If I call the empty constructor of my class I get no linker error, so it propably has to do with HWND. Have I forgotten something in my linker options?

Any idea why I'm getting this error? Thanks a lot

----------------------End of question 1--------------------

Also if anyone knows anything about wxWidgets, I'm also getting this linker error:

ParticleGUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxGLCanvas::wxGLCanvas(class wxWindow *,int,int *,class wxPoint const &,class wxSize const &,long,class wxString const &,class wxPalette const &)" (??0wxGLCanvas@@QAE@PAVwxWindow@@HPAHABVwxPoint@@ABVwxSize@@JABVwxString@@ABVwxPalette@@@Z) referenced in function "public: __thiscall ParticleGUI::ParticleGUI(class wxString const &,class wxSize)" (??0ParticleGUI@@QAE@ABVwxString@@VwxSize@@@Z)

I am including <wx/glcanvas.h> in that function. BUT to make it compile I had to change 4 header files of wxWidgets in its /include/ folder.
To enable wxGLCanvas I had to set in the setup.h files wxUSE_GLCANVAS to 1. And also had to correct a mistake in glcanvas.h file which had #if wxUSE_GLCANVAS instead of #ifdef wxUSE_GLCANVAS.
Then it finally compiled but I'm getting this linker error.
Someone told me that perhaps I have to recompile all the .lib's of wxWidgets now that I changed their header files,and that this might be what's causing this, but I got no idea how to do this
I got in my linker input both opengl32.lib and glut32.lib which was suggested somewhere

Any help appreciated

8 Years
Discussion Span
Last Post by Stepes

Read the error message more carefully! There is not a problem with HWND. It seems you have declared but not defined the ctor with the HWND parameter.


No I have actually defined it. That's the wierd thing. When I changed its parameter from HWND to int suddenly it finds the constructor!
The only thing I can think of is that since the linker says couldn't find PSystemManager::PSystemManager(struct HWND__ *) perhaps since my constructor is PSystemManager::PSystemManager(HWND) HWND =/= struct HWND__ *
But I created a ctor PSystemManager::PSystemManager(struct HWND__ *) and it said that I had already declared this ctor (pointing to the HWND one)
Which means HWND == struct HWND__ *
And in any case, my pgui->getDrawArea() returns HWND.
See why I find it so wierd? :/

Also I include in the PSystemManager the PSystemManager.h file, and in main.cpp too....


Are you sure that you really understand the difference between "declare" and "define" in C++? I think jencas was right and you don't DEFINE that constructor.



class PSystemManager {
	std::vector<string> systemTypes;
	std::vector<string> particleTypes;

	ParticleSystem* currSystem;
	Particle* currParticle;

	std::vector<string> getSystemTypes();
	std::vector<string> getParticleTypes();
	void changeCurrSystem(string type);
	void changeCurrParticle(string type);
	void Draw();

	PSystemManager(HWND wind); <----Declare


#include "./PSystemManager.h"
PSystemManager::PSystemManager(HWND wind){ <-----Define


	buffer = create_bitmap(SCREENW,SCREENH);;
   	myfont=load_font("tiza.pcx", NULL, NULL);
	currSystem = new LinearParticleSystem(textures, 0, 10, 10000,new RectEmitArea(new Rect(320,50,50,50)),100,AnimationFilmHolder::GetFilm("stars"));

	lastTimeCounted = getGameTime();

As far as I know that's defining and declaring and I'm doing both...

Hmmmmm when I choose go to definition in VS2008 it asks me to resolve the ambiguity and points me to both the declaration, and the definition(and the class definition)!!! For all the other functions there's no ambiguity :/
Am I doing something so obviously retarded that I can't see it?

Edit1: Okay so I went back to the basics now. Deleted everything except the ctor in the cpp file. And commented everything in the ctor. Still linker errors. Then I got angry and deleted everything from the cpp and simply added {} after the ctor in the class declaration PSystemManager(HWND wind){}; and it works :/ I'm getting crazy here. I'm sure the include in the cpp is right!

Edit2: Okay now I'm 100% convinced it has to do with HWND. I changed both declaration an definition of the ctor to have as parameter (ParticleSystem* currSystem) and voila no more linker errors...


Windows API HWND type is defined as void*, not struct HWND__ * . Obviously pgui->getDrawArea() returns another type (for example, MFC Cwnd is a simple HWND wrapper).


Only problem is I wrote the getDrawArea and it looks like this :/


class ParticleGUI : public wxFrame
    ParticleGUI(const wxString& title, wxSize size);
	HWND getDrawArea();

    wxNotebook *noteb;
	HWND wind;


HWND ParticleGUI::getDrawArea(){
	return wind;

I even tried casting the result of getDrawArea() to HWND and got the same link error.

Ok so I made my constructor to take struct HWND__ * as a parameter and it seems to shut up the linker.
Although I can't fathom why this would happen(and if its a good thing converting it like this)

Still need some help with the linker not accepting the wxGLCanvas constructor(look at first post). Do you think I need
to recompile the libs because I changed the header files in the wx/include/ folder?
(and if yes, how can I do it?)

Thanks for trying to help btw :)

Edi1: I guess this page tells how to compile it, but what build configuration should I choose? static debug?


Okay ignore the question about wxGLCanvas. Didn't need it after all. Lots of trouble for nothing.

Thanks alot for the help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.