#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
#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
// on_button_clicked() method. The on_button_clicked() method is defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*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;
}
运行#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;
}
结果出现g++ main.cc `pkg-config --cflags --libs gtkmm-2.4`
请问是什么地方出的问题?/tmp/ccpUPlk4.o: In function `main':
main.cc:(.text+0x3b): undefined reference to `HelloWorld::HelloWorld()'
main.cc:(.text+0x60): undefined reference to `HelloWorld::~HelloWorld()'
main.cc:(.text+0x77): undefined reference to `HelloWorld::~HelloWorld()'
collect2: ld 返回 1
应该怎么写这种Makefiles呢?
不好意思
学医的
以前是在dev-cpp下面
不会用automake