Author Topic: wxGLCanvas link errors (C::B 10.05)  (Read 9086 times)

Offline venom_zx

  • Single posting newcomer
  • *
  • Posts: 4
wxGLCanvas link errors (C::B 10.05)
« 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?
« Last Edit: June 05, 2010, 02:23:57 pm by venom_zx »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #1 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
(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!]

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #2 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.
« Last Edit: June 05, 2010, 03:12:39 pm by Biplab »
Be a part of the solution, not a part of the problem.

Offline venom_zx

  • Single posting newcomer
  • *
  • Posts: 4
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #3 on: June 05, 2010, 03:54:17 pm »
thanks! (after linking to "libwxmsw28_gl.a") that fixed the problem Biblab
« Last Edit: June 05, 2010, 03:56:19 pm by venom_zx »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #4 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
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.

Offline venom_zx

  • Single posting newcomer
  • *
  • Posts: 4
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #5 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)
« Last Edit: June 05, 2010, 07:40:22 pm by venom_zx »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #6 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.

« Last Edit: June 06, 2010, 01:51:55 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline venom_zx

  • Single posting newcomer
  • *
  • Posts: 4
Re: wxGLCanvas link errors (C::B 10.05)
« Reply #7 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
« Last Edit: June 06, 2010, 12:58:01 am by venom_zx »