How to configure GTK + for development using Code :: Blocks on Ubuntu Linux

I am trying to develop a GTK + application on Ubuntu 11.4 using Code :: Blocks.

www.gtk.org contains instructions for creating GTK + from a source, which looked complicated. But Ubuntu's package manager listed libgtk3-dev as the package I installed.

Code :: Blocks I installed using the Ubuntu Software Center.

Using the Code :: Blocks project wizard to create a GTK + project during assembly, the project cannot compile "cannot find gtk / gtk.h".

Obviously, the GTK include (and lib) folders are not added to the Code :: Blocks search folders. I found the appropriate paths and files ...

Should I explicitly and manually add all the search paths in the Code :: Blocks search path? Or I missed some installation step.

+6
source share
1 answer

Assuming you have found and installed the correct package. Since 2011, the current package has been libgtk-3-dev then the pkg-config tool could be used to extract the linker and compiler flags - and if it is properly escaped in the code: block settings can automatically enter the correct settings.

Go to Code :: Blocks Settings> Compiler and Linker Settings ... and add the following to 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' 

Using 'this leads to the launch of the pkg-config tool, which calls --cflags GTK+-3.0 (or --libs), which, assuming libgtk3-dev is installed, inserts the necessary search folders and lib directives into the gcc line command.


As an alternative, developer.ubuntu.com lists Anjuta as a C / C ++ IDE that can create GTK + projects. As an alternative to Code :: Blocks, it is much better developed as an Ubuntu IDE.


Erase it. Annie quickly loses her shine.

+20
source

Source: https://habr.com/ru/post/887514/


All Articles