本文介绍了在GTK2的应用程序在Ubuntu 12.04连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C GUI应用程序(在 GTK + 2.0 ),我用来链接如下:

I've a C GUI application (in GTK+2.0) that I used to link as follows :

gcc -O2 -std=gnu99 -pipe -Wall -lm `pkg-congig gtk+-2.0 `pkg-config --libs gtk+-2.0` -o exec a.o b.o c.o

这最终转化为:

gcc -O2 -std=gnu99 -pipe -Wall -lm -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64 linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12  -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lcairo -lgtk-x11-2.0 -lglib-2.0 -o exec a.o b.o c.o

这是直到的Ubuntu 12.04

当我试图把文件在Ubuntu 12.04的相同方式连接,以及,它显示了以下错误:

When I tried to link the files in the same way in Ubuntu 12.04 as well, it showed the following error :

/usr/bin/ld: b.o: undefined reference to symbol 'gdk_color_parse'
/usr/bin/ld: note: 'gdk_color_parse' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgdk-x11-2.0.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgdk-x11-2.0.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

如果任何人有这个任何想法,请分享一下。

If anyone has any idea about this please share.

推荐答案

随着海湾合作委员会/ binutils的,连接标志新版本必须放在最后,因为链接器的外观的只领先的未定义符号。尝试

With newer versions of GCC/binutils, linker flags have to come last because the linker looks ahead only for undefined symbols. Try

gcc -O2 -std=gnu99 -pipe -Wall a.o b.o c.o -lm `pkg-config --libs gtk+-2.0` -o exec

代替。

这篇关于在GTK2的应用程序在Ubuntu 12.04连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:21