Author Topic: CLI Compiles C:B doesn't wxBitMap  (Read 6876 times)

Offline jonas thomas

  • Multiple posting newcomer
  • *
  • Posts: 18
CLI Compiles C:B doesn't wxBitMap
« on: December 29, 2008, 05:39:58 pm »
Hello,
This is somewhat frustrating to me, since I know I'm missing something obvious
I don't know how to phrase the question to find my own answer from google.
I have been working my way through every each zetcode wxwidgets tutorial  http://www.zetcode.com/tutorials/wxwidgetstutorial/widgets/ using C::B IDE and this is the first piece of sample code that has stopped me dead in my tracks.
I can get the code below to compile and execute just fine from a the terminal... but no luck from the IDE.
I know this is a stupid newbie issue... Is there an FAQ or something that someone can point me to.

Code
#include "bitmapbutton.h"

BitmapButton::BitmapButton(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 130))
{
  wxImage::AddHandler( new wxPNGHandler );
  wxPanel *panel = new wxPanel(this);
  slider = new wxSlider(panel, ID_SLIDER, 0, 0, 100,
      wxPoint(10, 30), wxSize(140, -1));

  button = new wxBitmapButton(panel, wxID_ANY, wxBitmap(wxT("mute.png"),
      wxBITMAP_TYPE_PNG), wxPoint(180, 20));

  Connect(ID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
      wxScrollEventHandler(BitmapButton::OnScroll));
  Center();
}


void BitmapButton::OnScroll(wxScrollEvent& event)
{
  pos = slider->GetValue();

  if (pos == 0) {
      //button->SetBitmapLabel(wxBitmap(wxT("mute.png"), wxBITMAP_TYPE_PNG));
      button->SetBitmapLabel(wxBitmap(wxT("/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/mute.png"), wxBITMAP_TYPE_PNG));
  } else if (pos > 0 && pos <= 30 ) {
      //button->SetBitmapLabel(wxBitmap(wxT("min.png"), wxBITMAP_TYPE_PNG));
      button->SetBitmapLabel(wxBitmap(wxT("/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/min.png"), wxBITMAP_TYPE_PNG));
        } else if (pos > 30 && pos < 80 ) {
      //button->SetBitmapLabel(wxBitmap(wxT("med.png"), wxBITMAP_TYPE_PNG));
      button->SetBitmapLabel(wxBitmap(wxT("/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/med.png"), wxBITMAP_TYPE_PNG));
  } else {
      //button->SetBitmapLabel(wxBitmap(wxT("max.png"), wxBITMAP_TYPE_PNG));
      button->SetBitmapLabel(wxBitmap(wxT("/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/max.png"), wxBITMAP_TYPE_PNG));
  }
}
As I said from the terminal prompt, everything works fine:
Code
 g++ main.cpp main.h bitmapbutton.cpp bitmapbutton.h `wx-config --cxxflags --libs` -Wall -o runthisjunk2

I thought I was having some type of dependency issue so I switched to an absolute path and I'm still having this issue.
Apparently I'm compiling ok... It has something to do with linking....
Code
obj/Debug/bitmapbutton.o||In function `BitmapButton::OnScroll(wxScrollEvent&)':|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|26|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|26|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|26|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|29|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|29|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|29|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|32|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|32|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|32|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|35|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|35|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|35|undefined reference to `wxBitmap::~wxBitmap()'|
obj/Debug/bitmapbutton.o||In function `BitmapButton':|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|4|undefined reference to `wxFrameNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|4|undefined reference to `wxDefaultPosition'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|6|undefined reference to `wxImage::AddHandler(wxImageHandler*)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxPanelNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxDefaultSize'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxDefaultPosition'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|9|undefined reference to `wxSliderNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|9|undefined reference to `wxDefaultValidator'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxButtonNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxDefaultValidator'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxDefaultSize'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|15|undefined reference to `wxEVT_COMMAND_SLIDER_UPDATED'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|17|undefined reference to `wxFrame::~wxFrame()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|4|undefined reference to `wxFrameNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|4|undefined reference to `wxDefaultPosition'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|6|undefined reference to `wxImage::AddHandler(wxImageHandler*)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxPanelNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxDefaultSize'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|7|undefined reference to `wxDefaultPosition'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|9|undefined reference to `wxSliderNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|9|undefined reference to `wxDefaultValidator'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::wxBitmap(wxString const&, wxBitmapType)'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxButtonNameStr'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxDefaultValidator'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxDefaultSize'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|12|undefined reference to `wxBitmap::~wxBitmap()'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|15|undefined reference to `wxEVT_COMMAND_SLIDER_UPDATED'|
/home/jonas/projects/zetcode_tutorials/Widgets_I/wxBitmapButton/bitmapbutton.cpp|17|undefined reference to `wxFrame::~wxFrame()'|
obj/Debug/bitmapbutton.o||In function `wxStringBase::Init()':|
/usr/include/wx-2.8/wx/string.h|270|undefined reference to `wxEmptyString'|
obj/Debug/bitmapbutton.o||In function `wxObject':|
/usr/include/wx-2.8/wx/object.h|412|undefined reference to `vtable for wxObject'|
obj/Debug/bitmapbutton.o||In function `wxGDIObject':|
/usr/include/wx-2.8/wx/gdiobj.h|30|undefined reference to `vtable for wxGDIObject'|
obj/Debug/bitmapbutton.o||In function `wxBitmapBase':|
/usr/include/wx-2.8/wx/bitmap.h|119|undefined reference to `vtable for wxBitmapBase'|
obj/Debug/bitmapbutton.o||In function `wxBitmap':|
/usr/include/wx-2.8/wx/gtk/bitmap.h|53|undefined reference to `vtable for wxBitmap'|
obj/Debug/bitmapbutton.o||In function `~wxThreadHelperThread':|
/usr/include/wx-2.8/wx/thread.h|594|undefined reference to `wxThread::~wxThread()'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|






Offline jonas thomas

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: CLI Compiles C:B doesn't wxBitMap
« Reply #1 on: December 29, 2008, 07:12:36 pm »
Dohh... Ok... My problem is not a problem...
It turns out that I copied my compiler string as my linker string.
I just assumed that it was more of a problem than it was..
 :oops:
Basically, I've been using a blank project and copying and pasting from a previous project.
I should have paid closer attention..
Anyhow... I've been thinking about setting up a user template consisting of a blank project with just minimal settings so I could load up the zetcode wxwidget tutorials.   
I played with the templates a little bit but I didn't think it was worth the time to figure out how to do that....
I'm re-thinking that strategy..  Off hand does anyone have a how to.... they can point me to??

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: CLI Compiles C:B doesn't wxBitMap
« Reply #2 on: December 29, 2008, 07:55:44 pm »
Setup a blank project with the settings you need and save it as user template: "File -> Save project as user-template..." .

Offline jonas thomas

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: CLI Compiles C:B doesn't wxBitMap
« Reply #3 on: December 31, 2008, 02:52:05 pm »
[Edit]
(On the stuff below.... Never Mind... After the first few projects, you get used to the  differences)

This should probably be in a distinct thread...
I set up a template and tried creating a new project with it.

It seems that the program flow of a new project with a template defined is somewhat different than a empty project.

On the empty project, there is some very cool behavior in that you enter the project title and project filename as well a sub-directory get autogenerated for you also.  The auto generation of the sub-directory confused me at first  but after a couple of project I really love it.

It seems that if you apply a template, you don't get access to that feature.. Is that correct or am I missing something?
It appears that you need to put in the project directory and the project name in separately.
Perhaps it has to be this way, but darn it that other feature is a really nice creature comfort :)

JT

Btw (SVN 5340)



« Last Edit: January 01, 2009, 03:27:14 pm by jonas thomas »