Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-26-2005, 09:10 AM   #1
Registered: Dec 2003
Posts: 75

Rep: Reputation: 15
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.
Old 03-28-2005, 03:40 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
C++ is case sensitive.

HelloWorld != Helloworld


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
GTKmm or GTK+ ??? fei Programming 2 08-29-2005 01:56 AM
which powerful QT or GTKMM? Barq Linux - General 1 03-13-2005 12:39 PM
GTKmm Help gtkmike Programming 10 09-22-2004 09:32 AM
gtkmm HOW? Barq Programming 1 08-29-2004 08:43 AM
gtkmm-config .. where is it? v2-ncl Linux - Software 1 11-10-2003 10:04 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration