Page 1 of 1

irrEdit-style wxWidgets & Irrlicht integration

Posted: Thu Aug 24, 2006 6:51 am
by KevinCain
I write Irrlicht apps using VC+ 2005, with Code::Blocks as my IDE. Recently, thanks to the emminently helpful Ryan Pusztai & his wxPack, I've ben able to successfully integrate wxWidgets into the above setup.

Unfortunately, I'm having a bit of trouble getting Irrlicht and wxWidgets to play nice with each other.

1. I'm able to compile Nico's win32 Irrlicht tutorial. Here's a Code::Blocks project to prove it: www.insightdigital.org/Ryan/wxPack_Irrlicht_win32.7z

2. However, the same code yields linker errors when the project is ammended to include the required wxWindows project settings:
www.insightdigital.org/Ryan/win32_from_wizard.7z

Further explanation:

I can compile programs with a) the compiler/linker settings required for Irrlicht (console & Win32) and with b) wxWidgets, but not c) Win32 Irrlicht + wxWidgets settings together. That is, I can compile an run the win32 tutorial (#1, above) using a 'winmain' or 'main' methods, and I can compile wxWindows projects using the same methods. But when I add in the settings required by wxWindows (#2, above) the same code I used in case #1 results in linker errors.

Below are the Code::Blocks settings I'm using, followed by the linker errors generated. Of course, you can browse through the projects to view the settings as well.

Settings:

Global:

Project:Build Options:(top level above Debug/Release):Compiler:Compiler Flags:[/W3]

Project:Build Options:(top level above Debug/Release):Compiler:Other Options:none

Project:Build Options:(top level above Debug/Release):Compiler:#defines:none

Project:Build Options:(top level above Debug/Release):Linker:Irrlicht
Project:Build Options:(top level above Debug/Release):Linker:opengl32
Project:Build Options:(top level above Debug/Release):Linker:glu32
Project:Build Options:(top level above Debug/Release):Linker:gdi32

Project:Build Options:(top level above Debug/Release):Directories:Compiler:C:\irrlicht\irrlicht-1.1\include

Project:Build Options:(top level above Debug/Release):Directories:Linker:C:\irrlicht\irrlicht-1.1\lib\Win32-VisualStudio

Debug:

Project:Build Options:Debug:Compiler:Compiler Flags:[/Zi /D_DEBUG]

Project:Build Options:Debug:Compiler:Other Options:/Zi

Project:Build Options:Debug:Compiler:#defines:_DEBUG

Project:Build Options:Debug:Linker:none

Release:

Project:Build Options:Release:Compiler:Compiler Flags:[/Og]
Project:Build Options:Release:Compiler:Compiler Flags:[/Ox]
Project:Build Options:Release:Compiler:Compiler Flags:[/MD]

Project:Build Options:Release:Compiler:Other Options:none

Project:Build Options:Release:Compiler:#defines:NDEBUG

Project:Build Options:Release:Linker:none

Global Variables:none

---

Win32 settings derived from Code::Blocks wizard:

Project:Build Options:(top level above Debug/Release):Linker:gdi32
Project:Build Options:(top level above Debug/Release):Linker:user32
Project:Build Options:(top level above Debug/Release):Linker:kernel32

Project:Build Options:(top level above Debug/Release):Directories:Compiler:$(#psdk.include)

Project:Build Options:(top level above Debug/Release):Directories:Linker:$(#psdk.lib)

---

LINKER ERRORS:

-------------- Build: Debug in wxHelloWorld ---------------
dynamic.cpp
Linking console executable: C:\code\dynamic_frames_irr\bin\Debug\wxHelloWorld.exe
dynamic.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__GetMessageA@16 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__RegisterClassExA@4 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__LoadCursorA@8 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__LoadIconA@8 referenced in function _WinMain@16
dynamic.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall WindowProcedure(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z)
dynamic.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall WindowProcedure(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z)
C:\code\dynamic_frames_irr\bin\Debug\wxHelloWorld.exe : fatal error LNK1120: 10 unresolved externals
Process terminated with status 1120 (0 minutes, 0 seconds)
11 errors, 0 warnings

----

Thanks for any helpful notes you might be able to suggest. Since there is considerable interest in this forum on the topic of integrating Irrlicht with wxWidgets, I'd be happy to post project files for a working integration, if I can get there, of course. ;-)

-Kevin

Link errors fixed, on to integration

Posted: Thu Aug 24, 2006 3:57 pm
by KevinCain
With many thanks to Ryan Pusztai, I solved the linker problems posted above. He noticed that I was missing user32.lib in the linker settings. For a working Code::Blocks project, see: www.insightdigital.org/Ryan/integration_test.7z

Now, I'm looking carefully at the bits and pieces available from Nico on the subject of integrating Irrlicht with wxWidgets. In Nico's how-to (http://www.irrlicht3d.org/pivot/entry.php?id=347) he suggests using the wxWidgets method GetHandle() to place an Irrlicht window within a wxWindow frame.

Two questions:

1. Does this mean that we need a WINAPI WinMain method to implement a wxWidgets+Irrlicht app?

2. In Nico's Win32+Irrlicht tutorial, I understand how Nico initializes the IrrlichtDevice to the HWND handle of his Win32 window. Are there any syntax hints in extrapolating this approach to wxWidgets+Irrlicht rather than Win32+Irrlicht?

-Kevin

Posted: Thu Aug 31, 2006 9:49 pm
by jonasrf