-   Linux - Software (
-   -   gtkmm help (

paulr1984 03-26-2005 09:10 AM

gtkmm help
Hi! I'm having trouble compiling a very simple gtkmm application. I'm new to gtkmm. I have a class named HelloWorld. It is a window with a button. There are 3 files: helloworld.h,, I can't seem to compile Here's how I tried to compile it (not linking yet):

g++ -o helloworld.o -c `pkg-config gtkmm-2.4 --cflags`

I get this message: error: `Helloworld' has not been declared error: ISO C++ forbids declaration of `Helloworld' with no type In function `int Helloworld()': error: only constructors take base initializers error: `set_border_width' undeclared (first use this function) error: (Each undeclared identifier is reported only once for each function it appears in.) error: `m_button' undeclared (first use this function) error: invalid use of `this' in non-member function
helloworld.h:13: error: `virtual void HelloWorld::on_button_clicked()' is protected error: within this context error: `add' undeclared (first use this function)

Here's my code.


#include <gtkmm/button.h>
#include <gtkmm/window.h>

using namespace Gtk;

class HelloWorld : public Gtk::Window
  virtual ~HelloWorld();

  virtual void on_button_clicked();
  Button m_button;

#include "helloworld.h"
#include <iostream>

using namespace std;

  :  m_button( "Hello World" )
  set_border_width( 10 );
  m_button.signal_clicked().connect( sigc::mem_fun( *this, &HelloWorld::on_button_clicked ));
  add( m_button );;


void HelloWorld::on_button_clicked()
  cout << "Hello World" << endl;

#include <gtkmm/main.h>
#include "helloworld.h"

using namespace Gtk;

int main( int argc, char** argv )
  Main kit( argc, argv );
  HelloWorld helloworld;
  Main::run( helloworld );

  return 0;

Is there something wrong with the code or with how I compiled it? I'm sure I installed gtkmm properly. I can compile and run if everything was in one big file, not separated into headers and cc's anymore.

acid_kewpie 03-28-2005 03:40 AM

C++ is case sensitive.

HelloWorld != Helloworld

All times are GMT -5. The time now is 01:57 PM.