ubuntu 12.04环境下Code::Blo…

在ubuntu中,如果只是安装好gtk+后,用命令行编译的时候总是很麻烦,需要gcc `pkg-config --cflags --libs gtk+-3.0`类似的命令,所以为了方便,就想着在codeblocks下直接编译。

一跑发现会报gtk/gtk.h找不到的问题。在网上搜了下,中文帖子的解决方法只有  http://somuchhope.blog.163.com/blog/static/8995126420121744327801/  但是或许是因为版本的问题,这篇文章中的解决方法对我无效。

所以在stackoverflow搜了下,果然没有让我失望,让我找到了答案,具体见: http://stackoverflow.com/questions/5921460/how-to-setup-gtk-to-develop-with-codeblocks-on-ubuntu-linux

Open Code::Blocks Settings > Compiler and Linker Settings... and add the following under Global Compiler Settings > Compiler Settings > Other Options

`pkg-config --cflags gtk+-3.0`

and add this to Global Compiler Settings > Linker Settings > Other Options

`pkg-config --libs gtk+-3.0`

With the ` this has the effect of running the pkg-config tool calling --cflags gtk+-3.0 (or --libs) which, assuming libgtk3-dev is installed, injects the necessary search folders and lib directives onto the gcc command line.

另外,刚刚配好才发现的,codeblocks在建新工程的时候,有gtk proj可选。发现如果在新建的时候直接选择gtk proj,那么新建的proj中会自带一个depend文件,里面的内容是对引入对gtk包的依赖。如此一来,哪怕删掉上述的配置也能直接编译运行。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值