Bulding "OpenGL - cube" example in CodeBlocks, from wxPack Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
thor36
Knows some wx things
Knows some wx things
Posts: 35
Joined: Sat Feb 01, 2014 2:20 pm

Bulding "OpenGL - cube" example in CodeBlocks, from wxPack

Post by thor36 »

Hello all,
I have been trying to build and run the OpenGL example ( ...\wxWidgets3.0\samples\opengl\cube ) in CodeBlocks 13.12 with no success. I have x64 Windows 7 machine, and I have installed wxWidgets from wxPack 3.0 . Before that I was doing simple wxWidgets and OpenGL projects ( separately ) and there were no major issues.

When building I get errors because wxGLCanvas and and wxGLContext get "undefined references" errors. At the CodeBlocks forums I have learned that the probable reason is that wxWidgets in wxPack are compiled with "wxUSE_GLCANVAS" defined as 0, and as such there is no way to make the libraries work. The libraries that I linked to the project ( which should make OpenGL work with wxWidgets ) are "libwxmsw30u_gl.a" and "libwxmsw30ud_gl.a" .

Does anyone know a way around it, or perhaps how I could easily obtain the proper libraries without compiling entire wxWidgets and other efforts like that ( I am a beginner in programming, especially building projects using 3rd party libraries ). Thank you !
T
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: Bulding "OpenGL - cube" example in CodeBlocks, from wxPa

Post by Manolo »

I don't use wxPack, so I don't know if it's compiled with OGL support.

Each wx sample as a 'makefile' which makes compilation really easy.
To use it from CodeBlocks, look for "use makefile" option in project's options.

Yes, 'libwxmsw30ud_gl.a' or 'libwxmsw30u_gl.a' is needed for a static version of your app. Add one of these to C:B libs.
Which one?. Let's explain the name 'libwxmsw30ud_gl.a':
libwx: a lib file with wx code.
msw: For MSWindows only.
30: wx version. Don't mix versions!!!
u: with unicode support.
d: debug version (with symbols).
_gl: with OGL support.
.a: this is a static file, not a shared one.

If you already have 'libwxmsw30[ud]_gl.a' be aware that it must have been compiled with the same compiler as the rest of wx; otherwise, issues may arise.

While compiling wx from inside C:B is not very hard (there is a good tutorial in this forum, by T-Rex), compiling in a DOS box is even easier.
Just open a shell, command-prompt, box (ejecute command at Win start menu) and:
1) Be sure you have set the PATH enviroment to mingw/bin dirs.
2) Type something like:
>cd c:\wx301\build\msw
>mingw32-make -f makefile.gcc BUILD=debug UNICODE=1 USE_OPENGL=1
You can see more options at "install.txt" of wx doc's dirs
thor36
Knows some wx things
Knows some wx things
Posts: 35
Joined: Sat Feb 01, 2014 2:20 pm

Re: Bulding "OpenGL - cube" example in CodeBlocks, from wxPa

Post by thor36 »

Manolo, thank you very much for your kind and informative reply, I really appreciate it.

The example works now, and truly only thing to change was to take the library from MSW wxWidgets ( from SourceForge ), and not from wxPack. I suppose it must be documented somewhere in wxPack that this version won't support OpenGL, but I didn't know where to look for it.

I would like to add another question though, you have given the instructions for compiling wxWidgets in command prompt like this :
>cd c:\wx301\build\msw
>mingw32-make -f makefile.gcc BUILD=debug UNICODE=1 USE_OPENGL=1

Is the first line the location of downloaded wxWidgets ? If yes, what is then the location of compiled libraries ?
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: Bulding "OpenGL - cube" example in CodeBlocks, from wxPa

Post by Manolo »

>cd c:\wx301\build\msw
Replace 'c:\wx301' with the real full dir where wx downloaded source files are (let's call it "mywxdir").

If you look into this dir after compilation, you will see that at mywxdir\build\msw a new dir is added, with a name related to the compiler used. There is a lot of files, all of them "object files" used later to build the librar[y/es].

What really matters to you is that the libraries themselves are at mywxdir\lib\gcc_lib. Again, 'gcc_lib' is a compiler dependant name.