如何在Eclipse IDE for C/C++ Developers中正确编译GTK程序?(已解决)

<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 25.99431800842285px;  background-color: rgb(240, 240, 240);"><strong>(</strong></span><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; background-color: rgb(240, 240, 240); line-height: 25.99184799194336px;"><strong>已解决,详见<a target=_blank target="_blank" href="http://blog.csdn.net/acmerhlj/article/details/39720183" style="color: rgb(0, 0, 0); text-decoration: none; font-family: 'Microsoft YaHei'; line-height: 30px;">Ubuntu 12.04下在Eclipse IDE for C/C++ Developers中运行C语言的GTK程序</a></strong></span><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 25.99431800842285px;  background-color: rgb(240, 240, 240);"><strong>)</strong></span>
出现错误信息如下,请问大牛该如何解决?<strong><span style="font-size:14px;">(<span style="color: rgb(51, 51, 51); font-family: Arial; line-height: 25.99184799194336px;">已解决,详见<a target=_blank href="http://blog.csdn.net/acmerhlj/article/details/39720183" style="color: rgb(0, 0, 0); text-decoration: none; font-family: 'Microsoft YaHei'; line-height: 30px;">Ubuntu 12.04下在Eclipse IDE for C/C++ Developers中运行C语言的GTK程序</a></span>)</span></strong>
00:52:56 **** Incremental Build of configuration Debug for project Again ****
make all 
Building file: ../why.c
Invoking: GCC C Compiler
gcc "../why.c" -I/usr/include/glib-2.0 -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gtk-2.0 -O0 -g3 -Wall `pkg-config --cflags gtk+-2.0` -MMD -MP -MF"why.d" -MT"why.d" -o "why.o"
/tmp/cciyb0Cn.o: In function ‘main’:
/home/shw/workspace/Again/Debug/../why.c:5: undefined reference to ‘gtk_init’
/home/shw/workspace/Again/Debug/../why.c:6: undefined reference to ‘gtk_window_new’
/home/shw/workspace/Again/Debug/../why.c:7: undefined reference to ‘gtk_widget_show’
/home/shw/workspace/Again/Debug/../why.c:8: undefined reference to ‘gtk_main’
collect2: ld returned 1 exit status
make: *** [why.o] Error 1


已经安装Ubuntu(ubuntu-12.04-desktop-i386)、gtk 2.24.10、Eclipse IDE for C/C++ Developers(eclipse-cpp-luna-R-linux-gtk.tar);<span style="font-family: Arial, Helvetica, sans-serif;">在终端可以编译并显示用C写的gtk窗口,在Eclipse里能编译普通的C/C++程序。</span>已经按http://blog.csdn.net/sunny2038/article/details/7082164的方法配置过Eclipse;已经……<span style="font-family: Arial, Helvetica, sans-serif;">包含很多的头文件是因为提示找不到各个头文件,也尝试设置PKG_CONFIG_PATH。</span>还是出错,搜到类似问题(http://bbs.chinaunix.net/thread-3775510-1-1.html,http://bbs.csdn.net/topics/380110411),但还是改不好,太菜了!Ubuntu环境变量的设置是硬伤!求教大牛:如何才能在Eclipse IDE for C/C++ Developers中正确编译GTK程序?


测试的代码:
#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
        GtkWidget *window;
        gtk_init (&argc, &argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_show (window);
        gtk_main ();
        return 0;
}

 
 
 
 
 
 
 
 
 

猜你喜欢

转载自blog.csdn.net/acmerhlj/article/details/39706363