ubuntu eclipse 下驚醒GTK的配置(全)

来源:互联网 发布:网络大电影投资协议 编辑:程序博客网 时间:2024/05/22 03:03

偶然的想法想玩玩GTK,因为Qt就是对gtk的C++封装,想着gtk应该比qt更高的执行效率吧,下面分享下自己搭建的过程。

 

1、我的ubuntu虚拟机是安装了eclipse+cdt的,如果是安装了eclipse没有安装CDT,则要安装CDT: 
     .可以在Eclipse update中输入以下地址来安装:http://download.eclipse.org/tools/cdt/releases/ganymede

     .也可以下载CDT Master update : http://download.eclipse.org/tools/cdt/releases/ganymede/ 然后也是在Eclipse Update中选用本地路径来安装   CDT。具体路径为:Help-->Software updates-->Available Software,选择Add site-->local,然后把刚才下载好的CDT Master导入。最后在左边列表选项中选择CDT,右键选择安装就可以了。 

 

2、安装相关依赖包

1sudo apt-get install gnome-core-devel
2sudo apt-get install libglib2.0-doc libgtk2.0-doc
3sudo apt-get install devhelp
4sudo apt-get install glade-gnome glade-common glade-doc
 
上面的几个我都没有安装,我直接运行sudo apt-get install libgtk2.0-dev libgnome2-dev ,这条命令最后没有执行完,系统提示需要升级update后才可以,在笔者测试过程中发现,两种方法都可以进行测试成功,但是sudo apt-get install libgtk2.0-dev libgnome2-dev,该种方法,可能会有漏洞,编译过程中,会有提示缺少文件,所以还是建议,使用上述四种安装方法,除了第一个安装过程可能比较慢以外,其他三种都很快的。
   $ : pkg-config --modversion gtk+-2.0    输出: 2.20.1
 

如果是在终端下直接编译的话,可以方便的输入GTK+的include、lib依赖,即在gcc 命令后加上`pkg-config --cflags --libs gtk+-2.0`注意`这个符号是1签名那个键,还有在这段字符之前加个空格)。

比如:gcc -o testGtk `pkg-config --cflags --libs gtk+-2.0` testGtk.c

 

3、在Eclipse下开发效率略高。用法:新建project new->c project,然后对这个project按如下步骤配置:
在project->properties->c/c++ build 下 Setting : 在GCC C Complier下Miscellaneous的other flags追加
`pkg-config --cflags --libs gtk+-2.0`注意`这个符号是1签名那个键,还有在这段字符之前加个空格)。

同样的方法在GCC C Linker下Miscellaneous的Linker flags(注意是Linker flags不是Other options)下添加`pkg-config --cflags --libs gtk+-2.0`注意`这个符号是1签名那个键,还有在这段字符之前加个空格)。另外)右键项目->Properties->C/C++ Build->Settings->GCC C Compiler->Directories,加入/usr/include/gtk-2.0 和 /usr/include/glib-2.0 这个是为了方便智能提示。

這樣如果還不行,並且出現了/bin/sh: 1: gcc-pthread: not found該提示,那麼在Properties->C/C++ Build->Settings->GCC Linker-中的Command Line pattern中的${INPUTS}放在${COMMAND}的後面,這樣就大功告成了,但是,如果中途出現No such file 這樣的錯誤提示的華,那麼就需要針對不同的文件進行不同的處理

引用blog.sina.com.cn/s/blog_4c02ba150101mpq8.html的解決辦法,就可以解決

错误记录

<1>

In file included from../../../third-party/distrib/sdl-1.2.12/src/video/x11/SDL_x11dyn.c:26:0:
../../../third-party/distrib/sdl-1.2.12/src/video/x11/SDL_x11dyn.h:39:33:fatal error: X11/extensions/XShm.h: No such file or directory
compilation terminated.
make[2]: *** [SDL_x11dyn.lo] Error 1

解决:

sudo apt-get install x11proto-xext-dev

sudo apt-get install  xorg-dev

<2>/usr/bin/ld: cannot find–liconv

解决:下载 libiconv http://ftp.gnu.org/gnu/libiconv/

$tar xvf libiconv-1.14.tar.gz

$cd libiconv-1.14

$./configure –prefix=/usr/local

$make;

错误记录

<2.1>./stdio.h:1010:1: error:'gets' undeclared here (not in a function)

解决:参见http://forum.z27315.com/topic/15662-解决编译libiconv时的gets-undeclared-here错误/

修改srclib/stdio.in.h 第695行

如下:

//_GL_WARN_ON_USE (gets, "gets is a securityhole - use fgets instead");
#if defined(__GLIBC__) &&!defined(__UCLIBC__) &&!__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole -use fgets instead");
#endif

 

<3>touchscreen_s3c6410/touchscreen_s3c6410.h:4:21:fatal error: gtk/gtk.h: No such file or directory

解决:sudo apt-get install libgtk2.0-dev

<4>/usr/include/glib-2.0/glib/gtypes.h:34:24:fatal error: glibconfig.h: No such file or directory

解决:

sudo cp/usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h /usr/include/
<5>

/usr/include/gtk-2.0/gdk/gdkscreen.h:31:19: fatal error:cairo.h: No such file or directory

解决:

sudo cp /usr/include/cairo/*  /usr/include/

<6>fatal error: pango/pango.h: Nosuch file or directory

解决:cp -r /usr/include/pango-1.0/pango/ /usr/include/

<7>fatal error: gdkconfig.h: Nosuch file or directory

解决:cp /usr/lib/x86_64-linux-gnu/gtk-2.0/include/gdkconfig.h/usr/include/

<8>)fatal error:gdk-pixbuf/gdk-pixbuf.h: No such file or directory compilationterminated.

解决:

sudo cp -r /usr/include/gdk-pixbuf-2.0/gdk-pixbuf/usr/include/

<9>fatal error: atk/atk.h: No suchfile or directory

解决:cp -r /usr/include/atk-1.0/atk/ /usr/include/

还有一点,就是可能在我们进行文件或者文件夹的复制过程中出现文件找不到的错误,这样的话,我们可以在自己的电脑上对该文件进行搜索,找到之后查看属性,就能知道该文件的路径了,然后修改下源文件路径即可。如果在文件的复制过程中出现权限拒绝,就在最前面加上sudo,我想这点就不用我说了吧...

這樣,最後就能在eclipse中進行圖形界面的開發了....好糾結的說...
0 0
原创粉丝点击