Linker errors while trying to add wxSpinReal

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
gamer.cpp
In need of some credit
In need of some credit
Posts: 9
Joined: Sat Feb 23, 2008 7:59 pm

Linker errors while trying to add wxSpinReal

Post by gamer.cpp »

Hi! I need spin controls based on real numbers so I found wxwidgets extension - wxSpinReal. I copied files to paths that were wrote in readme and when I'm compiling my project I recieve a lot of unresolved externals. If this kind of extensions expects some extra combinations or I'm doing sth wrong? Thanks for help, gamer.cpp.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Post the exact error messages, otherwise there's no way to tell
gamer.cpp
In need of some credit
In need of some credit
Posts: 9
Joined: Sat Feb 23, 2008 7:59 pm

Post by gamer.cpp »

Code: Select all

error LNK2019: unresolved external symbol "public: bool __thiscall wxSpinReal::Create(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,float,float,float,float,int,class wxString const &)" (?Create@wxSpinReal@@QAE_NPAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@JMMMMH1@Z) referenced in function "public: __thiscall wxSpinReal::wxSpinReal(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,float,float,float,float,int,class wxString const &)" (??0wxSpinReal@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@JMMMMH1@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual class wxClassInfo * __thiscall wxSpinReal::GetClassInfo(void)const " (?GetClassInfo@wxSpinReal@@UBEPAVwxClassInfo@@XZ)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual struct wxEventTable const * __thiscall wxSpinReal::GetEventTable(void)const " (?GetEventTable@wxSpinReal@@MBEPBUwxEventTable@@XZ)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual class wxEventHashTable & __thiscall wxSpinReal::GetEventHashTable(void)const " (?GetEventHashTable@wxSpinReal@@MBEAAVwxEventHashTable@@XZ)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxSpinReal::Show(bool)" (?Show@wxSpinReal@@UAE_N_N@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxSpinReal::Enable(bool)" (?Enable@wxSpinReal@@UAE_N_N@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxSpinReal::SetFocus(void)" (?SetFocus@wxSpinReal@@UAEXXZ)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxSpinReal::SetFont(class wxFont const &)" (?SetFont@wxSpinReal@@UAE_NABVwxFont@@@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall wxSpinReal::DoGetPosition(int *,int *)const " (?DoGetPosition@wxSpinReal@@MBEXPAH0@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall wxSpinReal::DoGetSize(int *,int *)const " (?DoGetSize@wxSpinReal@@MBEXPAH0@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual class wxSize __thiscall wxSpinReal::DoGetBestSize(void)const " (?DoGetBestSize@wxSpinReal@@MBE?AVwxSize@@XZ)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall wxSpinReal::DoMoveWindow(int,int,int,int)" (?DoMoveWindow@wxSpinReal@@MAEXHHHH@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxSpinReal::SetValue(float)" (?SetValue@wxSpinReal@@UAEXM@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxSpinReal::SetRange(float,float)" (?SetRange@wxSpinReal@@UAEXMM@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxSpinReal::SetIncrement(float,int)" (?SetIncrement@wxSpinReal@@UAEXMH@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxSpinReal::SetSnap(bool)" (?SetSnap@wxSpinReal@@UAEX_N@Z)
HelloWorldApp.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall wxSpinReal::GetValue(void)" (?GetValue@wxSpinReal@@UAEMXZ)
HelloWorldApp.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall wxSpinReal::~wxSpinReal(void)" (??1wxSpinReal@@UAE@XZ) referenced in function "public: virtual void * __thiscall wxSpinReal::`scalar deleting destructor'(unsigned int)" (??_GwxSpinReal@@UAEPAXI@Z)
It looks like class doesn't see it's methods bodies which are in cpp file. This methods which causes errors are virtual but their bodies exist in cpp file.
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

are the cpp files being compiled(for each .cpp file do you have a .o file), ie... wxSpinReal.cpp/wxSpinReal.o

Are the .o files being linked to the application?

What compiler are you using? Could you post the link command that gave this error with its options.

-Max
gamer.cpp
In need of some credit
In need of some credit
Posts: 9
Joined: Sat Feb 23, 2008 7:59 pm

Post by gamer.cpp »

are the cpp files being compiled(for each .cpp file do you have a .o file), ie... wxSpinReal.cpp/wxSpinReal.o
Yes, I added files to wxwidgets project (core) and I rebuilded it. I have obj files (*.o no).
Are the .o files being linked to the application?
Err, I dont understand. I'm including only wxwidgets *.h files and wxwidgets libraries.
What compiler are you using? Could you post the link command that gave this error with its options.
I'm using visual express 2008.

When I'm creating pointer

Code: Select all

wxSpinReal *spinReal
I haven't any errors, but when I do this:

Code: Select all

spinReal = new wxSpinReal(...)
I'm recieving errors. Also this construction:

Code: Select all

wxSpinReal spinReal

causes errors.
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 »

gamer.cpp wrote:when I do this:

Code: Select all

spinReal = new wxSpinReal(...)
Maybe I'm still rusty on my C++, but you have to declare a variable type when creating it, no?

Code: Select all

wxSpinReal *spinReal = new wxSpinReal(...)
FlyingIsFun1217
gamer.cpp
In need of some credit
In need of some credit
Posts: 9
Joined: Sat Feb 23, 2008 7:59 pm

Post by gamer.cpp »

FlyingIsFun1217 wrote:
gamer.cpp wrote:when I do this:

Code: Select all

spinReal = new wxSpinReal(...)
Maybe I'm still rusty on my C++, but you have to declare a variable type when creating it, no?

Code: Select all

wxSpinReal *spinReal = new wxSpinReal(...)
FlyingIsFun1217
No, I'm doing sth like that

Code: Select all

wxSpinReal *spinReal;
spinReal = new wxSpinReal(...)
So it's ok. Compiling is ok, I have errors when linking.
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

gamer.cpp wrote:[
Are the .o files being linked to the application?
Err, I dont understand. I'm including only wxwidgets *.h files and wxwidgets libraries.
The all the .o files need to be linked to the project as well as the libraries. If you include a wxSpinReal header file in main.cpp for main.o will be expecting to symbols defined in the header file to be provided in a library or a .o file.

Unfortunatly I don't know how to tell visual express to link against wxSpinReal.o(or whatever the .o files are).

-Max
gamer.cpp
In need of some credit
In need of some credit
Posts: 9
Joined: Sat Feb 23, 2008 7:59 pm

Post by gamer.cpp »

mc2r wrote:
gamer.cpp wrote:[
Are the .o files being linked to the application?
Err, I dont understand. I'm including only wxwidgets *.h files and wxwidgets libraries.
The all the .o files need to be linked to the project as well as the libraries. If you include a wxSpinReal header file in main.cpp for main.o will be expecting to symbols defined in the header file to be provided in a library or a .o file.

Unfortunatly I don't know how to tell visual express to link against wxSpinReal.o(or whatever the .o files are).

-Max
Are you sure? I've searched for *.o files through all wxWidgets files and I haven't found any *.o files. Maybe they are only in unix/linux systems? But I have many *.obj files - I think it can be this what you mean. wxSpinReal.obj is created but I don't know if it's linked to my app.

Any other ideas?

offtopic: why spinbuttons can only count integer values in standard wxWidgets? I think it isn't very difficult to code... :)
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I'm not sure .o files apply to VC, i know they apply to GCC but it may be that VC doesn't use them (no idea)

in any case, my guess is that the control's code is not being built and linked against. Did you add the file to your target? If you modifiy the code file and hit build, does it rebuild?
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post by mc2r »

gamer.cpp wrote:Are you sure? I've searched for *.o files through all wxWidgets files and I haven't found any *.o files.
The .o extension might be a gcc only thing, but your cpp files still need to be compiled into object files of some sort and linked to the app. I'm really not sure at all how that works with visual express.

-Max
Post Reply