wxWidgets and OpenGL frustration!!!

This is a discussion on wxWidgets and OpenGL frustration!!! within the C++ Programming forums, part of the General Programming Boards category; I installed Dev Cpp, along with the wxWidgets devpak and I can successfully compile both a widgets program and a ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    58

    wxWidgets and OpenGL frustration!!!

    I installed Dev Cpp, along with the wxWidgets devpak and I can successfully compile both a widgets program and a opengl program, however separately.

    I want to incorporate glcanvas into my wxwidgets program, but every time I try to compile I get these linker errors:

    [Linker error] undefined reference to `wxGLCanvas::SetCurrent(wxGLContext const&) const'

    [Linker error] undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'

    [Linker error] undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'

    [Linker error] undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'

    [Linker error] undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'

    [Linker error] undefined reference to `wxGLCanvas::SwapBuffers()'

    [Linker error] undefined reference to `wxGLCanvas::sm_eventTable'

    [Linker error] undefined reference to `wxGLCanvas::GetClassInfo() const'

    [Linker error] undefined reference to `wxGLCanvas::~wxGLCanvas()'

    [Linker error] undefined reference to `wxGLCanvas::~wxGLCanvas()'

    ld returned 1 exit status

    C:\Users\user\Desktop\Makefile.win [Build Error] [Project1.exe] Error 1





    I just don't get it... I included -lopengl32 to the linker parameters and I even changed the setup.h file to allow opengl use. However all I did was change the value in the setup.h file and not recompile anything, seeing I don't know how

    if anyone could shed some light on this mess I would be more than ecstatic... thanks!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    > I just don't get it... I included -lopengl32 to the linker parameters
    But it seems to be complaining about wxWidgets symbols, so include wxWidgets libraries?

    Also, check each demo program for all the linker options and libraries.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Location
    Tempe, AZ
    Posts
    2
    Quote Originally Posted by parad0x13 View Post
    I just don't get it... I included -lopengl32 to the linker parameters and I even changed the setup.h file to allow opengl use. However all I did was change the value in the setup.h file and not recompile anything, seeing I don't know how

    if anyone could shed some light on this mess I would be more than ecstatic... thanks!
    That's it then, you do have to recompile after changing the header file- otherwise wxGLCanvas just isn't there no matter what you do. That said, I did recompile, there are some pretty thorough instructions in various places, including the Code::Blocks wiki, the library recompiled without a hitch, yet when I try to compile an example program to demonstrate wxGLCanvas, I too get linker errors, though of a different sort:

    Code:
    obj\Debug\wxSimpleGLMain.o||In function `ZN8GLCanvasC2EP7wxFrameRK6wxSizePi':|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|49|undefined reference to `_imp___ZN10wxGLCanvasC2EP8wxWindowiPiRK7wxPointRK6wxSizelRK8wxStringRK9wxPalette'|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|51|undefined reference to `_imp___ZN11wxGLContextC1EP10wxGLCanvasPKS_'|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|51|undefined reference to `_imp___ZN10wxGLCanvasD2Ev'|
    obj\Debug\wxSimpleGLMain.o||In function `ZN8GLCanvasC1EP7wxFrameRK6wxSizePi':|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|49|undefined reference to `_imp___ZN10wxGLCanvasC2EP8wxWindowiPiRK7wxPointRK6wxSizelRK8wxStringRK9wxPalette'|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|51|undefined reference to `_imp___ZN11wxGLContextC1EP10wxGLCanvasPKS_'|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|51|undefined reference to `_imp___ZN10wxGLCanvasD2Ev'|
    obj\Debug\wxSimpleGLMain.o||In function `ZN8GLCanvas5paintER12wxPaintEvent':|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|63|undefined reference to `_imp___ZNK10wxGLCanvas10SetCurrentERK11wxGLContext'|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|70|undefined reference to `_imp___ZN10wxGLCanvas11SwapBuffersEv'|
    obj\Debug\wxSimpleGLMain.o||In function `Z41__static_initialization_and_destruction_0ii':|
    C:\Documents and Settings\Mischa\My Documents\Programming\wxSimpleGL\wxSimpleGLMain.cpp|36|undefined reference to `_imp___ZN10wxGLCanvas13sm_eventTableE'|
    obj\Debug\wxSimpleGLMain.o||In function `ZNK12wxWindowBase11GetBestSizeEv':|
    C:\SourceCode\Libraries\wxWidgets-2.8.9\include\wx\window.h:(.rdata$_ZTV8GLCanvas[vtable for GLCanvas]+0x8)||undefined reference to `wxGLCanvas::GetClassInfo() const'|
    C:\SourceCode\Libraries\wxWidgets-2.8.9\include\wx\window.h:(.text$_ZN8GLCanvasD1Ev[GLCanvas::~GLCanvas()]+0x16)||undefined reference to `_imp___ZN10wxGLCanvasD2Ev'|
    C:\SourceCode\Libraries\wxWidgets-2.8.9\include\wx\window.h:(.text$_ZN8GLCanvasD0Ev[GLCanvas::~GLCanvas()]+0x16)||undefined reference to `_imp___ZN10wxGLCanvasD2Ev'|
    I'm admittedly very much a n00b when it comes to C and C++, I can usually figure out compiler errors, but linker errors confound me, I can't tell if I've missed something, or if the example program is bad, but I'm more inclined to think I'm doing something wrong... I have linked to opengl32, glu32, and of course the appropriate wxwidgets library- I'm able to compile other wxwidgets programs since rebuilding it, but nothing with wxGLCanvas

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    What are the compile/link lines that are executing? They should be printing somewhere that you can cut and paste from.

  5. #5
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Among my wx libraries (in the lib folder) there is something called libwxmsw27_ogl.a which looks like something you should link to.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  6. #6
    Registered User
    Join Date
    Mar 2009
    Location
    Tempe, AZ
    Posts
    2
    Quote Originally Posted by anon View Post
    Among my wx libraries (in the lib folder) there is something called libwxmsw27_ogl.a which looks like something you should link to.
    I didn't have that file, if I had seen that I might have made the connection- I was poking around with the makefile, which led me to the file config.gcc, which defines USE_OPENGL := 0, so not only do we have to edit setup.h, but also this- I edited the makefile, but I'm sure I could just as well specify it on the command line, but so I don't forget if I rebuild... So anywho, one rebuild later, I now have a new lib file, libwxmsw28_gl.a, and with it included, the example program compiles, links, and runs, woohoo.

Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21