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包的依賴。如此一來,哪怕刪掉上述的配置也能直接編譯運行。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章