LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-26-2005, 08:10 AM   #1
paulr1984
Member
 
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, helloworld.cc, main.cc. I can't seem to compile helloworld.cc. Here's how I tried to compile it (not linking yet):

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

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

Here's my code.

helloworld.h
Code:
#include <gtkmm/button.h>
#include <gtkmm/window.h>

using namespace Gtk;

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

protected:
  virtual void on_button_clicked();
  Button m_button;
};

helloworld.cc
Code:
#include "helloworld.h"
#include <iostream>

using namespace std;

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

HelloWorld::~HelloWorld()
{
}

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

main.cc
Code:
#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, 02:40 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

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

HelloWorld != Helloworld
 
  


Reply


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 12:56 AM
which powerful QT or GTKMM? Barq Linux - General 1 03-13-2005 11:39 AM
GTKmm Help gtkmike Programming 10 09-22-2004 08:32 AM
gtkmm HOW? Barq Programming 1 08-29-2004 07:43 AM
gtkmm-config .. where is it? v2-ncl Linux - Software 1 11-10-2003 09:04 PM


All times are GMT -5. The time now is 03:20 PM.

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