今天我尝试编写一个简单的HelloWorld程序 在c ++中使用gtkmm库。当我尝试使用编译时编译:
g++ `pkg-config --cflags --libs gtkmm-3.0` main.cc -o main
链接器告诉我这个:
/tmp/ccY4sTsR.o: nella funzione "main":
main.cc:(.text+0x36): undefined reference "Gtk::Main::Main(int&, char**&, bool)"
main.cc:(.text+0x50):undefined reference to"Gtk::Window::Window(Gtk::WindowType)"
main.cc:(.text+0x65): undefined reference "Glib::ustring::ustring(char const*)"
main.cc:(.text+0x78): undefined reference to "Gtk::Window::set_title(Glib::ustring const&)"
main.cc:(.text+0x84): undefined reference to"Glib::ustring::~ustring()"
main.cc:(.text+0x97): undefined reference to"Gtk::Main::run(Gtk::Window&)"
main.cc:(.text+0xa8): undefined reference to "Gtk::Main::~Main()"
main.cc:(.text+0xda): reference not defined to "Glib::ustring::~ustring()"
main.cc:(.text+0xeb): reference not defined to "Gtk::Main::~Main()"
collect2: error: ld returned 1 exit status
所以我检查了libgtkmm-2.0是否安装使用:
dpkg -l|grep gtkmm
它告诉我:
ii gtkmm-documentation 3.18.0-1 all Documentation of C++ wrappers for GLib/GTK+
ri libgtkmm-2.4-1v5:amd64 1:2.24.4-2 amd64 C++ wrappers for GTK+ (shared libraries)
ii libgtkmm-2.4-dbg:amd64 1:2.24.4-2 amd64 C++ wrappers for GTK+ (debug symbols)
ii libgtkmm-2.4-dev:amd64 1:2.24.4-2 amd64 C++ wrappers for GTK+ (development files)
ii libgtkmm-2.4-doc 1:2.24.4-2 all C++ wrappers for GTK+ (documentation)
ri libgtkmm-3.0-1v5:amd64 3.18.0-1 amd64 C++ wrappers for GTK+ (shared libraries)
ii libgtkmm-3.0-dbg:amd64 3.18.0-1 amd64 C++ wrappers for GTK+ (debug symbols)
ii libgtkmm-3.0-dev:amd64 3.18.0-1 amd64 C++ wrappers for GTK+ (development files)
ii libgtkmm-3.0-doc 3.18.0-1 all C++ wrappers for GTK+ (documentation)
main.cc文件的代码是:
#include <gtkmm.h>
#include <gtkmm/window.h>
#include <gtkmm/main.h>
int
main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Gtk::Window* main_win = new Gtk::Window (Gtk::WINDOW_TOPLEVEL);
main_win->set_title ("prove");
if (main_win)
{
kit.run(*main_win);
}
return 0;
}
谁能帮助我?