Author Topic: Errors when building an example that combines wxWidgets and OpenGL  (Read 6417 times)

Offline thor36

  • Multiple posting newcomer
  • *
  • Posts: 32
Hello all
I am trying to get up and running a wxWidgets example that also uses OpenGL. I downloaded compiled wxWidgets in form of wxPack. Before that I have been writing simple applications using widgets and also OpenGL ( separately ) without any major issues. If anywone has wxWidgets 3.0 installed, the example I am trying to get running is located in ...\wxWidgets3.0\samples\opengl\cube

When trying to build the example I get 15 errors, which are :

Code
||=== Build: Debug in cubePrimercek (compiler: GNU GCC Compiler) ===|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|37|warning: "wxUSE_GLCANVAS" redefined [enabled by default]|
O:\SourceCode\Libraries\wxWidgets3.0\include\wx\setup.h|1318|note: this is the location of the previous definition|    obj\Debug\cube.o||In function `ZN13TestGLContextC2EP10wxGLCanvas':|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|146|undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|148|undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|146|undefined reference to `wxGLContext::~wxGLContext()'|obj\Debug\cube.o||In function `ZN12TestGLCanvasC2EP8wxWindowPi':|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|338|undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int const*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|338|undefined reference to `wxGLCanvas::~wxGLCanvas()'|obj\Debug\cube.o||In function `ZN7MyFrameC2Eb':|
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|500|undefined reference to `wxGLCanvasBase::IsDisplaySupported(int const*)'|obj\Debug\cube.o:cube.cpp:(.rdata+0x248)||undefined reference to `wxGLCanvas::sm_eventTable'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x8)||undefined reference to `wxGLCanvas::GetClassInfo() const'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x368)||undefined reference to `wxGLCanvas::SwapBuffers()'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x370)||undefined reference to `wxGLCanvas::CreateDefaultPalette()'|obj\Debug\cube.o||In function `ZN12TestGLCanvasD1Ev':|
N:\projekticpp\wxWidgets\cubePrimercek\cube.h|66|undefined reference to `wxGLCanvas::~wxGLCanvas()'|
N:\projekticpp\wxWidgets\cubePrimercek\cube.h|66|undefined reference to `wxGLCanvas::~wxGLCanvas()'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x8)||undefined reference to `wxGLContext::GetClassInfo() const'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x1c)||undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'|obj\Debug\cube.o||In function `ZN13TestGLContextD1Ev':|    
N:\projekticpp\wxWidgets\cubePrimercek\cube.h|18|undefined reference to `wxGLContext::~wxGLContext()'|
||=== Build failed: 15 error(s), 1 warning(s) (0 minute(s), 9 second(s)) ===|

From what I know, the reason for these errors is not including "libwxmsw30u_gl.a" and "libwxmsw30ud_gl.a" . However I have included them both ( from "lib" and "lib64" folders ) to the linker settings -> link libraries in the CodeBlocks project. I have added the folders of these libraries to project -> search directories -> linker as well. And also to global CodeBlocks compiler settings in search directories -> linker. But the errors persist. I don't know why these libraries don't get linked to the project, since the build log writes them out. Here it is in the first anaconda line ( sorry I didn't find how to make it more readable ) :

Code

-------------- Build: Debug in cubePrimercek (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -LO:\SourceCode\Libraries\wxWidgets3.0\lib\gcc_dll -LO:\SourceCode\Libraries\wxWidgets3.0\lib\gcc48_lib -LO:\SourceCode\Libraries\wxWidgets3.0\lib64\gcc48_dll -LO:\SourceCode\Libraries\wxWidgets3.0\lib64\gcc48_lib -LO:\SourceCode\Libraries\wxWidgets3.0\lib\gcc_dll -LN:\opencv\build\x86\mingw\lib -LO:\SourceCode\Libraries\wxWidgets3.0\lib\gcc48_lib -LO:\SourceCode\Libraries\wxWidgets3.0\lib64\gcc48_lib -o bin\Debug\cubePrimercek.exe obj\Debug\cube.o  obj\Debug\resource.res -mthreads  -lwxmsw30u -lopengl32 -lglu32 O:\SourceCode\Libraries\wxWidgets3.0\lib64\gcc48_lib\libwxmsw30ud_gl.a O:\SourceCode\Libraries\wxWidgets3.0\lib64\gcc48_lib\libwxmsw30u_gl.a O:\SourceCode\Libraries\wxWidgets3.0\lib\gcc48_lib\libwxmsw30ud_gl.a O:\SourceCode\Libraries\wxWidgets3.0\lib\gcc48_lib\libwxmsw30u_gl.a N:\opencv\build\x86\mingw\lib\libopencv_calib3d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_calib3d246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_contrib_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_contrib246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_core_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_core246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_features2d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_features2d246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_flann_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_flann246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_gpu_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_gpu246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_haartraining_engine.a N:\opencv\build\x86\mingw\lib\libopencv_highgui_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_highgui246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_imgproc_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_imgproc246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_legacy_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_legacy246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_ml_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_ml246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_nonfree_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_nonfree246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_objdetect_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_objdetect246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_perf_calib3d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_core_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_features2d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_gpu_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_highgui_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_imgproc_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_nonfree_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_objdetect_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_photo_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_stitching_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_superres_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_perf_video_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_photo_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_photo246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_stitching_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_stitching246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_superres_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_superres246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_test_calib3d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_contrib_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_core_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_features2d_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_flann_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_gpu_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_highgui_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_imgproc_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_legacy_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_ml_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_nonfree_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_objdetect_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_photo_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_stitching_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_superres_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_test_video_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_ts_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_ts246.a N:\opencv\build\x86\mingw\lib\libopencv_video_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_video246.dll.a N:\opencv\build\x86\mingw\lib\libopencv_videostab_pch_dephelp.a N:\opencv\build\x86\mingw\lib\libopencv_videostab246.dll.a -mwindows
obj\Debug\cube.o: In function `ZN13TestGLContextC2EP10wxGLCanvas':
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:147: undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:149: undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:147: undefined reference to `wxGLContext::~wxGLContext()'
obj\Debug\cube.o: In function `ZN12TestGLCanvasC2EP8wxWindowPi':
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:339: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int const*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:339: undefined reference to `wxGLCanvas::~wxGLCanvas()'
obj\Debug\cube.o: In function `ZN7MyFrameC2Eb':
N:/projekticpp/wxWidgets/cubePrimercek/cube.cpp:501: undefined reference to `wxGLCanvasBase::IsDisplaySupported(int const*)'
obj\Debug\cube.o:cube.cpp:(.rdata+0x248): undefined reference to `wxGLCanvas::sm_eventTable'
obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x8): undefined reference to `wxGLCanvas::GetClassInfo() const'
obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x368): undefined reference to `wxGLCanvas::SwapBuffers()'
obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x370): undefined reference to `wxGLCanvas::CreateDefaultPalette()'
obj\Debug\cube.o: In function `ZN12TestGLCanvasD1Ev':
N:/projekticpp/wxWidgets/cubePrimercek/cube.h:65: undefined reference to `wxGLCanvas::~wxGLCanvas()'
N:/projekticpp/wxWidgets/cubePrimercek/cube.h:65: undefined reference to `wxGLCanvas::~wxGLCanvas()'
obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x8): undefined reference to `wxGLContext::GetClassInfo() const'
obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x1c): undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'
obj\Debug\cube.o: In function `ZN13TestGLContextD1Ev':
N:/projekticpp/wxWidgets/cubePrimercek/cube.h:17: undefined reference to `wxGLContext::~wxGLContext()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 3 second(s))
15 error(s), 0 warning(s) (0 minute(s), 3 second(s))

I am using CodeBlocks 13.12 on a Windows 7 x64 machine. Although I have been doing both wxWidgets and OpenGL projects in CodeBlocks before, they were really simple. So I am still a beginner and any kind of help and extra info will be very much appreciated.
Thank you !  :)
T

« Last Edit: May 31, 2014, 04:15:25 am by thor36 »

Online stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #1 on: May 31, 2014, 04:25:58 am »
You likely need to post on the wxWidgets forum. Edit http://forums.wxwidgets.org/
And, remember to post the Build Log NOT the "message log" on that site and also this site in the future.
Edit2: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Step 1 is to figure out what caused this message!!!!!
Code
N:\projekticpp\wxWidgets\cubePrimercek\cube.cpp|37|warning: "wxUSE_GLCANVAS" redefined [enabled by default]|

Tim S.
« Last Edit: May 31, 2014, 04:32:36 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 thor36

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #2 on: May 31, 2014, 04:33:14 am »
Tim,
I have first talked to a wxWidgets guru who told me that the issue is in adding the 2 libraries I have mentioned. But not being a CodeBlocks user himself he pointed me to this forum, since he saw the problem being in the environment / build process.

The redefined wxUSE_CANVAS is fine. Without redefining it ( from '0' to '1' ), it would be an error.

Just to be sure about what you said, the first part of messages I copied in my post was unnecessary, only the second part was relevant ?

Thank you,
T

Online stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #3 on: May 31, 2014, 09:03:04 am »
If you posted a full rebuild log some one could help; since you can NOT no one can help you.
Try reading this FAQ!!!!!!!!! http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

You ARE wrong redefining the value of wxUSE_CANVAS is likely the cause of the problem!!!!

Where is it defined as zero?

Please learn to compile wxWidgets!! Please learn to ask your wxWidgets questions in the wxWidgets forum!!

From the sample; please read the errors you get instead of trying to hide them!!!!!!
Code
#if !wxUSE_GLCANVAS
    #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
#endif

Tim S.
« Last Edit: May 31, 2014, 10:07:45 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 thor36

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #4 on: May 31, 2014, 12:53:17 pm »
Tim,
I have redefined wxUSE_CANVAS to 1, that is what the warning says. If I didn't, I would get the error that you have copied in your previous post. Namely - "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library". So after I redefine it to 1 as it's required, I get the warning message, which looks more like a "reminder" , that some important value is changed, to me anyhow.

And apologies if I didn't post the build information properly.
Regards, T

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #5 on: May 31, 2014, 01:08:33 pm »
It says set the value to 1 and rebuild the library, as it is a wxWidgets sample, it means rebuild the wxWidgets library.
If wxPack has build the lib without "wxUSE_CANVAS" set to "1" you will most likely fail.

Offline thor36

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Errors when building an example that combines wxWidgets and OpenGL
« Reply #6 on: May 31, 2014, 01:19:56 pm »
Thank you jens, this important bit has slipped me. I will seek further assistance at wxWidgets forum.
Regards, T