Page 1 of 1

winsock.h or winsock2.h can i choose?

Posted: Sun Jun 03, 2007 9:45 pm
by Sunsawe
Hi,

I'm developping a small project under windows with visual studio 2005.
I am using a librairie in my project which uses winsock2.h
But the wxWidget part of the project use winsock.h and of course there are issues and compil time errors.

What is the difference between winsock.h and winsock2.h? Are they 2 completely different things or just updates? Is it possible to set wxWidgets to use winsock2.h? can it work with it?

thank you

Posted: Mon Jun 04, 2007 10:50 am
by Kervala
What does happen if you include winsock2.h before wx.h ?

In new Windows SDK, windows.h is including winsock.h excepted if some defines are defined (which ones are also defined in winsock2.h) :)

Posted: Mon Jun 04, 2007 10:28 pm
by Sunsawe
well i tried but...
If the part of the project that i was looking for can compil, the main project gives:

Code: Select all

hello.obj : error LNK2001: unresolved external symbol "public: virtual class wxClassInfo * __thiscall wxEvtHandler::GetClassInfoW(void)const " ([email protected]@@[email protected]@XZ)
TestFrame.obj : error LNK2001: unresolved external symbol "public: virtual class wxClassInfo * __thiscall wxEvtHandler::GetClassInfoW(void)const " ([email protected]@@[email protected]@XZ)
TestFrame.obj : error LNK2001: unresolved external symbol "public: virtual class wxClassInfo * __thiscall wxGDIObject::GetClassInfoW(void)const " ([email protected]@@[email protected]@XZ)
do you know how to solve that ones?

Posted: Mon Jun 04, 2007 10:45 pm
by Kervala
You surely forgot IMPLEMENT_CLASS() macro in the .cpp file for your class :)

Posted: Tue Jun 05, 2007 6:17 am
by Sunsawe
Actually... i have never used that before...
But i tried, i had

Code: Select all

DECLARE_CLASS(class);
in the two classes (.h file) deriving from a wxWidgets class and

Code: Select all

IMPLEMENT_CLASS(classname, baseclass)
in their cpp files.

Then it does.... nothing!

Still have exactly the same errors. I also tried with

Code: Select all

DECLARE_DYNAMIC_CLASS
and same result!


:(

Posted: Tue Jun 05, 2007 7:39 am
by Kervala
Did you inherite your class from a wxObject derivated class ?

Posted: Tue Jun 05, 2007 11:09 am
by Sunsawe
my classes are inheriting from wxApp and wxFrame.

Posted: Tue Jun 05, 2007 11:27 am
by Kervala
Good :)

What else...

Did you link your program to correct libraries ?

Posted: Tue Jun 05, 2007 4:38 pm
by Sunsawe
well....
i'm not linking explicitely with anything. i'm using the automatic linking (don't know exactly how it works but it does...)

Why including winsock2.h is creating those errors? Something is missing in the linking thing obviously but which part of wxWidgets?

:cry:

Posted: Wed Jun 06, 2007 10:43 pm
by Sunsawe
i found on the net.
Including wx/msw/winundef.h right after winsock2.h solved the problem.

Posted: Thu Jun 07, 2007 8:46 am
by Kervala
Hehe, well done :p