将 gtkmm 与 Eclipse CDT 结合使用
我正在尝试编译 gtkmm Simple使用 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
抱歉,错误日志很长,但是我不知道如何缩短它
I'm trying to compile the gtkmm Simple Example using Eclipse CDT, but it's not working for some reason
I'm compiling this on Mandriva Linux and GCC 4.4.3
I get this error, which I think is a linking error :
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
Sorry for the long error log, but I don't know how to make it shorter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
项目属性->C/C++ Build->Settings
GCC C++ Compiler->Miscellaneous,将此字符串:
pkg-config gtkmm-3.0 --cflags --libs
添加到其他标志中。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) 字符串。
Project Property->C/C++ Build->Settings
GCC C++ Compiler->Miscellaneous, add this string:
pkg-config gtkmm-3.0 --cflags --libs
into Other flags.GCC C++ Linker->Miscellaneous, add this string:
pkg-config gtkmm-3.0 --cflags --libs
in Linker flags.If you are using gtkmm 2.4, just replace "gtkmm-3.0" with "gtkmm-2.4"
Tick the GCC C++ COMPILER VERBOSE (_V) string.
在 Eclipse 终端中运行
pkg-config gtkmm-2.4 --cflags --libs
时,您必须添加列出的所有库。据我发现,Eclipse 与 pkg-config 配合得不好,因此您必须手动添加它们。右键单击您的项目>属性> C/C++ 构建 >设置
在 GCC C++ 编译器下的目录中,添加运行时列出的每个目录
pkg-config gtkmm-2.4 --cflags
(仅目录,删除 -I 和 -pthread)
在 GCC C++ Linker 下的 Libraries 中,添加来自
pkg-config --libs
(同样,只需添加库,删除 -l 和 -pthread)
You have to add all the library's listed when you run
pkg-config gtkmm-2.4 --cflags --libs
in a terminal to Eclipse. As far as I have found, Eclipse doesn't play nice with pkg-config, so you have to add them manually.Right click your Project > Properties > C/C++ Build > Settings
Under GCC C++ Compiler, in directories, add each directory listed when you run
pkg-config gtkmm-2.4 --cflags
(just the directories, drop the -I and -pthread)
Under GCC C++ Linker, in Libraries, add everything from
pkg-config --libs
(again, just add the libraries,drop the -l and -pthread)