Code::Blocks Forums

User forums => Help => Topic started by: venom_zx on June 05, 2010, 02:18:20 pm

Title: wxGLCanvas link errors (C::B 10.05)
Post by: venom_zx on June 05, 2010, 02:18:20 pm
i want to make use of OpenGL using the wxGLCanvas control/class, but whenever i create a clean wxWidgets project and just drop wxGLCanvas ( without any other changes ) onto my frame based application with wxSmith i get these link errors:


obj\Release\opengltestMain.o:opengltestMain.cpp|| undefined reference to `_imp___ZN10wxGLCanvasC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPiRK9wxPalette'|
obj\Release\opengltestMain.o:opengltestMain.cpp|| undefined reference to `_imp___ZN10wxGLCanvasC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPiRK9wxPalette'|
||=== Build finished: 2 errors, 0 warnings ===|


i've built wxMSW with mingw using:
mingw32-make.exe -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 USE_OPENGL=1

afterwards i went and changed "setup.h" in my "<WXWIN>\lib\gcc_dll\msw\wx" directory:
replaced: #define wxUSE_GLCANVAS       0
with:     #define wxUSE_GLCANVAS       1

my project is using linking to "libwxmsw28.a" (by default). also linking "libwxmsw28_gl.a" did not help.

i've tried this with wxMSW 2.8.10 and also 2.8.11.
i'm on windows xp using codeblocks-10.05mingw-setup

am i doing something wrong?
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: oBFusCATed on June 05, 2010, 03:05:32 pm
Does these two libs define the missing symbols (probably no)?

The way to check is this:
nm libwxmsw28.a | grep _imp___ZN10wxGLCanvasC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPiRK9wxPalette
or
nm libwxmsw28.a > result.txt then open the file in a text editor and search for _imp___ZN10wxGLCanvasC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxStringPiRK9wxPalette
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: Biplab on June 05, 2010, 03:10:14 pm
I believe your wx-opengl library was not built correctly.

The problem is that when you issue USE_OPENGL=1 to make it doesn't change the setup.h file. Result is that the dll generated by makefile doesn't export any functions. Even though one changes wxUSE_GLCANVAS to 1, binary generated previously doesn't have any exported functions. So you'll get linker error if you try to link against that dll. See the following ticket where I had provided patch to fix this issue.

Quote
http://trac.wxwidgets.org/ticket/10832

Solution is -
1) Change #define wxUSE_GLCANVAS       1 in setup.h file.
2) Then rebuild the wxWidgets binary or at least recompile wxOpenGl source & rebuild wxOpengl dll.
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: venom_zx on June 05, 2010, 03:54:17 pm
thanks! (after linking to "libwxmsw28_gl.a") that fixed the problem Biblab
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: ollydbg on June 05, 2010, 04:06:42 pm
BTW:
There is a wiki of the full details, see here:
Compiling wxWidgets 2.8.9 Monolithic Build with openGL for Windows (http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.8.9_Monolithic_Build_with_openGL_for_Windows)
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: venom_zx on June 05, 2010, 07:38:13 pm
ollydbg yeah, i actually saw this page and i got a lot of information from it.

but it also confused me because:

- i only had a "setup.h" file after doing a build and it was not located at "include/wx/msw/setup.h"
but at
"lib/gcc_dll/msw/wx/setup.h"

- it tells me to make sure "setup.h" is deleted after doing a clean (which is the file i just edited)

i wasn't able to conclude from that page that i had to leave "setup.h" inplace after doing a clean, for doing a rebuild (which seemed to solve my problem). and i'm still suprised that it worked (because i used the same build options in the rebuild)
Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: stahta01 on June 05, 2010, 09:28:43 pm
ollydbg yeah, i actually saw this page and i got a lot of information from it.

but it also confused me because:

- i only had a "setup.h" file after doing a build and it was not located at "include/wx/msw/setup.h"
but at
"lib/gcc_dll/msw/wx/setup.h"

- it tells me to make sure "setup.h" is deleted after doing a clean (which is the file i just edited)

i wasn't able to conclude from that page that i had to leave "setup.h" inplace after doing a clean, for doing a rebuild (which seemed to solve my problem). and i'm still suprised that it worked (because i used the same build options in the rebuild)

I added the step to copy setup0.h to setup.h in "include/wx/msw" folder.

Does the directions make sense to you now?

There is three setup files involved:
1: include\wx\msw\setup0.h            
The file setup0.h from the wxWidgets team and should not be changed by users.

2: include\wx\msw\setup.h              makefile creates if it does not exist from msw\setup0.h
The file msw\setup.h is where the user should make changes that needs to exist in all builds

3: lib\gcc_dll\mswu\wx\setup.h        makefile creates from msw\setup.h
Changing the file mswu\wx\setup.h only changes this build.

An forth setup.h I added just so I can find it using Google
4: include\msvc\wx\msw\setup.h     Should only be used by MS Visual C++ Compilers; and, best not to use it even there.

Tim S.

Title: Re: wxGLCanvas link errors (C::B 10.05)
Post by: venom_zx on June 06, 2010, 12:52:45 am
hey Tim,

that works even better. now i don't have to rebuilt and only edit 1 setup.h file for debug, release, etc builds.
the wiki page is clear now.

thanks  :D