News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

wxGLCanvas link errors (C::B 10.05)

Started by venom_zx, June 05, 2010, 02:18:20 PM

Previous topic - Next topic

venom_zx

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?

oBFusCATed

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
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Biplab

#2
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.

Quotehttp://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.
Be a part of the solution, not a part of the problem.

venom_zx

#3
thanks! (after linking to "libwxmsw28_gl.a") that fixed the problem Biblab

ollydbg

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

venom_zx

#5
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)

stahta01

#6
Quote from: 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)

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.

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

venom_zx

#7
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