Compiling errors

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.
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Compiling errors

Post by NonoNano »

Hello,

I'm new to raspberry pi/c++ but I'm trying to develop an application that is grabbing/showing a real time video in this environment.
This is my setup:
  • OS: Raspbian
    IDE: Codeblocks
    Language: C++
    GUI: wxWidgets
    Camera: Basler, pylon libraries
I'm trying to compile the project that was kindly given me here:

viewtopic.php?f=1&t=44421&start=60#p183279

that is based on OpenGl but I get these errors at compile time:

Code: Select all

obj/Debug/CameraGUIForm.o||In function `wxGLCanvas::~wxGLCanvas()':|
/usr/include/wx-3.0/wx/gtk/glcanvas.h|20|undefined reference to `wxGLCanvasX11::~wxGLCanvasX11()'|
/usr/include/wx-3.0/wx/gtk/glcanvas.h|20|undefined reference to `vtable for wxGLCanvas'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::GLBitmapPanel(wxWindow*, int, wxPoint const&, wxSize const&)':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|15|undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int const*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|21|undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::Render()':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|39|undefined reference to `glPixelZoom'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|40|undefined reference to `glRasterPos2i'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|41|undefined reference to `glDrawPixels'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::SetupGL()':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|94|undefined reference to `glEnable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|95|undefined reference to `glDepthMask'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|96|undefined reference to `glDisable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|98|undefined reference to `glMatrixMode'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|99|undefined reference to `glLoadIdentity'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|101|undefined reference to `glOrtho'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|102|undefined reference to `glViewport'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|104|undefined reference to `glMatrixMode'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|105|undefined reference to `glLoadIdentity'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|107|undefined reference to `glEnable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|108|undefined reference to `glBlendFunc'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|111|undefined reference to `glClearColor'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|112|undefined reference to `glClear'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x8)||undefined reference to `wxGLCanvas::GetClassInfo() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0xfc)||undefined reference to `wxGLCanvasX11::IsShownOnScreen() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x19c)||undefined reference to `wxGLCanvas::SetBackgroundStyle(wxBackgroundStyle)'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x230)||undefined reference to `wxGLCanvas::OnInternalIdle()'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x310)||undefined reference to `wxGLCanvasX11::SwapBuffers()'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x31c)||undefined reference to `wxGLCanvas::GetXWindow() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTI13GLBitmapPanel[_ZTI13GLBitmapPanel]+0x8)||undefined reference to `typeinfo for wxGLCanvas'|
||=== Build failed: 27 error(s), 152 warning(s) (1 minute(s), 10 second(s)) ===|
Do you have any idea on how to get rid of them? Thanks!
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

After a bit of Googling i found this:
https://stackoverflow.com/questions/396 ... onstructor

So try "wx-config --libs gl" in a console window. It should tell you the name of a library, similar to "wx_gtk2u_gl-3.1". Add that to the linker input files in C:B.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

Thank you! I will try it asap! I only would like to stress that I didn't explicitely installed in my OS anything related with OpenGL until now..should I? Moreover where do you think I will have to search for the library with the name "wx_gtk2u_gl-3.1" or similar? should I install something new or it is supposed to be in some of the libraries I'm already using?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

I don't know. Hopefully general OpenGL support is already installed on your system. Are there any OpenGL screensavers?

viewtopic.php?p=183278#p183278
In this post you showed the wxWidgets libraries on your system, libwx_gtk2u_gl-3.0.so is probably the one you need to add to your project.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

Ok, this is the output from that command:
-L/usr/lib/arm-linux-gnueabihf -pthread -lwx_gtk2u_gl-3.0 -lwx_baseu-3.0
these are libraries that are not listed in the ones I have installed..probably I miss them. The point is that I don't know where to find them! Somebody has any experience on this? Thanks!

EDIT:

I don't have
lwx_gtk2u_gl-3.0
but I have
libwx_gtk2u_gl-3.0
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

the "-l" in the beginning is the linker option. Did you try adding the lib to the CB project? Match the entry to the ones that are already there.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

Almost there!

Linking all those libraries most of the errors are gone..I get only this one:

Code: Select all

/usr/bin/ld: obj/Debug/CameraGUIForm.o||undefined reference to symbol 'glDepthMask'|
which is not related with a particular line of code (IDE is not pointing me in a particular place)
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

Hmm, that doesn't look good. Try commenting out the line with glDepthMask in gl_bitmap_panel.h. I have a feeling that you'll get another error then.

I just built one of the OpenGL samples under Linux in a VM and i also see the libs "GL" and "GLUT" getting linked to it. Try adding those, too.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

You are right now I get this error:
/usr/bin/ld: obj/Debug/CameraGUIForm.o||undefined reference to symbol 'glOrtho'|
where do I find those lib?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

Hopefully they are somewhere on the system and are found automatically. Just try it.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

This is all I can find

Code: Select all

root@raspberrypi:/home/pi# find / -name "*glut*"
/usr/share/codeblocks/templates/glut-main.cpp
/usr/share/codeblocks/templates/glut.png
/usr/share/codeblocks/templates/wizard/glut
/home/pi/wxWidgets/buildroot/package/libfreeglut
/home/pi/wxWidgets/buildroot/package/libfreeglut/libfreeglut.hash
/home/pi/wxWidgets/buildroot/package/libfreeglut/libfreeglut.mk
but it seems to me there are no libraries in there
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

Did you try to just add the names to the linker and See what happens?

If they are really missing, try googling for it, there is probably a package you can install.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

I linked some libraries and now it compiles (libGLU.so, libglut.so, libGL,so). Unfortunately the application isn't working properly: the buttons are hidden beyond the panel, if I bring the cursor above the button it is shown for a brief time and I can click on it. If I click on grab it seems to start grabbing but only the very first frame is shown, for the rest of the time the panel is 'blinking' (as it is doing something) but it is not refreshing. Morover watching with 'top' the CPU usage the value is 150% (don't know how it is possible)
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Compiling errors

Post by doublemax »

Unfortunately the application isn't working properly: the buttons are hidden beyond the panel, if I bring the cursor above the button it is shown for a brief time and I can click on it.
That's because you're using absolute positioning for the controls and they partly overlap. You can ignore that for now.
If I click on grab it seems to start grabbing but only the very first frame is shown, for the rest of the time the panel is 'blinking' (as it is doing something) but it is not refreshing.
If it's in this state and you move a window from another program over the window, does it partly refresh then?

Did you put the line with glDepthMask back in?

Please create a small test app with the following code (there is a hard-coded image path you need to adjust):

Code: Select all

#include <wx/wx.h>
#include "gl_bitmap_panel.h"

class MyApp: public wxApp
{
public:
   virtual bool OnInit();
};

wxIMPLEMENT_APP(MyApp);

class TestFrame : public wxFrame
{

public:
   TestFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
   : wxFrame(NULL, wxID_ANY, title, pos, size, wxCAPTION | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX | wxRESIZE_BORDER)
   {
      wxPanel *panel = new wxPanel(this, wxID_ANY);
      panel->SetBackgroundColour( wxColor(200,255,200) );

      wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
      m_gl_panel = new GLBitmapPanel(panel, wxID_ANY, wxDefaultPosition, wxSize(640,480) );

      main_sizer->Add( m_gl_panel, 0, wxALL, 4);

      panel->SetSizer( main_sizer );

      ::wxInitAllImageHandlers();
      m_img.LoadFile( "d:\\test.jpg", wxBITMAP_TYPE_JPEG );
      m_gl_panel->SetImage( m_img );

      //Bind(wxEVT_IDLE, &TestFrame::OnIdle, this );
   }

   void OnIdle( wxIdleEvent &event )
   {
     m_gl_panel->SetImage( m_img );
     event.RequestMore();
   }

private:
   GLBitmapPanel *m_gl_panel;
   wxImage m_img;
};

bool MyApp::OnInit()
{
   TestFrame *frame = new TestFrame("GL BITMAP TEST", wxPoint(64, 64), wxSize(800, 600));
   frame->Show( true );
   return true;
}
If this works, then the OpenGL part is ok, there is "just" a thread-related issue.
Use the source, Luke!
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Compiling errors

Post by NonoNano »

If I move the window the image is not displayed..it doesn't change anything.
Trying the application it works in a weird way: it displays the image but in black and white with some strange horizontal strips (while the original one is coulored and well defined).
Attachments
2018-04-06-002247_800x480_scrot.png
1.jpg
1.jpg (30.15 KiB) Viewed 4743 times
Post Reply