tim99
26-01-2004, 19:53
Hallo,
ich habe meine ersten Schritte mit gtkmm gewagt. Hab also erstmal mit dem obligatorischen Hello World angefangen.
Wenn ich jetzt compilieren möchte mit:
g++ main.cc -o helloworld `pkg-config gtkmm-2.0 --cflags --libs`
dann bekomm ich folgende Fehlermeldung:
/tmp/ccD4sBYP.o(.text+0x3c): In function `main':
: undefined reference to `helloworld::helloworld[in-charge]()'
/tmp/ccD4sBYP.o(.text+0x52): In function `main':
: undefined reference to `helloworld::~helloworld [in-charge]()'
/tmp/ccD4sBYP.o(.text+0x70): In function `main':
: undefined reference to `helloworld::~helloworld [in-charge]()'
collect2: ld returned 1 exit status
Ist nicht so ein guter Anfang... Wäre für jede Hilfe dankbar!
Tim
PS: Hier meine Dateien:
main.cc
#include <gtkmm/main.h>
#include "helloworld.h"
int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
helloworld helloworld;
Gtk::Main::run(helloworld); //Shows the window and returns when it is closed.
return 0;
}
helloworld.h
#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
#define GTKMM_EXAMPLE_HELLOWORLD_H
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class helloworld : public Gtk::Window
{
public:
helloworld();
virtual ~helloworld();
protected:
//Signal handlers:
virtual void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
};
#endif // GTKMM_EXAMPLE_HELLOWORLD_H
helloworld.cc
#include "helloworld.h"
#include <iostream>
helloworld::helloworld()
: m_button("Hello World") // creates a new button with the label "Hello World".
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// hello() method. The hello() method is defined below.
m_button.signal_clicked().connect(SigC::slot(*this , &HelloWorld::on_button_clicked));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}
ich habe meine ersten Schritte mit gtkmm gewagt. Hab also erstmal mit dem obligatorischen Hello World angefangen.
Wenn ich jetzt compilieren möchte mit:
g++ main.cc -o helloworld `pkg-config gtkmm-2.0 --cflags --libs`
dann bekomm ich folgende Fehlermeldung:
/tmp/ccD4sBYP.o(.text+0x3c): In function `main':
: undefined reference to `helloworld::helloworld[in-charge]()'
/tmp/ccD4sBYP.o(.text+0x52): In function `main':
: undefined reference to `helloworld::~helloworld [in-charge]()'
/tmp/ccD4sBYP.o(.text+0x70): In function `main':
: undefined reference to `helloworld::~helloworld [in-charge]()'
collect2: ld returned 1 exit status
Ist nicht so ein guter Anfang... Wäre für jede Hilfe dankbar!
Tim
PS: Hier meine Dateien:
main.cc
#include <gtkmm/main.h>
#include "helloworld.h"
int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
helloworld helloworld;
Gtk::Main::run(helloworld); //Shows the window and returns when it is closed.
return 0;
}
helloworld.h
#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
#define GTKMM_EXAMPLE_HELLOWORLD_H
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class helloworld : public Gtk::Window
{
public:
helloworld();
virtual ~helloworld();
protected:
//Signal handlers:
virtual void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
};
#endif // GTKMM_EXAMPLE_HELLOWORLD_H
helloworld.cc
#include "helloworld.h"
#include <iostream>
helloworld::helloworld()
: m_button("Hello World") // creates a new button with the label "Hello World".
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// hello() method. The hello() method is defined below.
m_button.signal_clicked().connect(SigC::slot(*this , &HelloWorld::on_button_clicked));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}