我正在尝试编译 gtkmm Simple Example使用 Eclipse CDT,但由于某种原因无法正常工作
我在 Mandriva Linux 和 GCC 4.4.3 上编译这个
我收到此错误,我认为这是一个链接错误:
Building target: Test
Invoking: GCC C++ Linker
g++ -L/usr/include/gtkmm-2.4 -o"Test" ./test.o
./test.o: In function `main':
test.cpp:(.text+0x39): undefined reference to `Gtk::Main::Main(int&, char**&, bool)'
test.cpp:(.text+0x43): undefined reference to `Gtk::Window::Window(Gtk::WindowType)'
test.cpp:(.text+0x4b): undefined reference to `Gtk::Main::run(Gtk::Window&)'
test.cpp:(.text+0x53): undefined reference to `Gtk::Window::~Window()'
test.cpp:(.text+0x5b): undefined reference to `Gtk::Main::~Main()'
test.cpp:(.text+0x82): undefined reference to `Gtk::Main::~Main()'
test.cpp:(.text+0x95): undefined reference to `Gtk::Window::~Window()'
./test.o: In function `global constructors keyed to main':
test.cpp:(.text+0xaf): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0xbe): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0xd2): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0xe1): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0xf5): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x104): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x118): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x127): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x13b): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x14a): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x15e): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x16d): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x181): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x190): undefined reference to `Glib::ustring::~ustring()'
collect2: ld returned 1 exit status
make: *** [Test] Error 1
抱歉,错误日志很长,但我不知道如何让它更短
最佳答案
项目属性->C/C++ 构建->设置
GCC C++ Compiler->Miscellaneous,将此字符串:pkg-config gtkmm-3.0 --cflags --libs
添加到 Other flags 中。
GCC C++ Linker->Miscellaneous,在 Linker flags 中添加以下字符串:pkg-config gtkmm-3.0 --cflags --libs
。
如果您使用的是 gtkmm 2.4,只需将“gtkmm-3.0”替换为“gtkmm-2.4”
勾选 GCC C++ COMPILER VERBOSE (_V) 字符串。
关于linux - 将 gtkmm 与 Eclipse CDT 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4957396/