这个gtkmm演示程序应该怎么编译阿?

软件和网站开发以及相关技术探讨
回复
chosen
帖子: 20
注册时间: 2006-02-02 22:37

这个gtkmm演示程序应该怎么编译阿?

#1

帖子 chosen » 2006-05-13 15:38

是gtkmm的演示程序
#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
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2006-05-13 18:10

makefile不会写。用anjuta,就都有了。autogen, automake,antuconfigure都安装了。anjuta选gtkmm工程,建立一个。都会自动配置好的。
● 鸣学
chosen
帖子: 20
注册时间: 2006-02-02 22:37

#3

帖子 chosen » 2006-05-13 18:56

anjuta不认我用的gtkmm 2.4啊
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2006-05-13 19:14

libgtkmm-2.4-doc - C++ wrappers for GTK+ 2.4 (documentation)

dapper就是2.4的。试试。
● 鸣学
chosen
帖子: 20
注册时间: 2006-02-02 22:37

#5

帖子 chosen » 2006-05-14 12:49

问题解决了
原来是编译的时候没有把helloworld.cc加进去
果真是菜啊
bs自己一下

代码: 全选

g++ main.cc helloworld.cc `pkg-config --cflags --libs gtkmm-2.4`
ltkun
帖子: 1340
注册时间: 2006-01-10 19:09

#6

帖子 ltkun » 2006-09-11 16:28

我也在看gtkmm的文档哈
有机会探讨一下
头像
titainium
帖子: 689
注册时间: 2006-12-02 12:25

#7

帖子 titainium » 2007-03-14 11:24

eclipse不认gtkmm的头文件路径,看起来要自己写makefile,麻烦。 :?
Titainium
antonym55
帖子: 353
注册时间: 2007-04-03 9:52
联系:

#8

帖子 antonym55 » 2007-05-21 16:33

titainium 写了:eclipse不认gtkmm的头文件路径,看起来要自己写makefile,麻烦。 :?
eclipse是可以认gtkmm的头文件, 不过我是自己写的Makefile(我用eclipse都是自己写Makefile)

我试了一下,如果不自己写的话,会错认为是gtkmm2.0, 而我装的是2.4

自己写Makefile就没这个问题了
回复