Include GTK libs

General questions regarding the usage of CodeLite
jsjs
CodeLite Curious
Posts: 3
Joined: Sun Mar 26, 2017 1:05 am
Genuine User: Yes
IDE Question: C++
Contact:

Include GTK libs

Post by jsjs »

Hello,

I am more or less new to Codelite and I am having some trouble.

I just created a new C-project. I downloaded Homebrew and installed GTK3 and some other stuff.
Now, I try to include the gtk header file via

Code: Select all

#include <gtk/gtk.h>
, but the library is not found.
I already searched the whole Internet for an answer, but nothing really worked for me, f.ex. I tried to type the path to the header file to Linker and Compiler an Build options with no success.
If I build the project from the Terminal, its very easy, I just have to type

Code: Select all

gcc -o main.c base 'pkg-config --cflags gtk+-3.0' 
and it works fine for me.
Now my question to you: is there any possibility to get this work within Codelite? Because I don't want to run and build my project from the Terminal, but just to click CMD/CTRL + R, this is much easier :-)

Hope you can help me, if you have any further questions, please let me know! ;-)

Kind regards
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Include GTK libs

Post by eranif »

In:

project settings->Compiler->C options
and also in:
project settings->Compiler->C++ options

Add:

Code: Select all

$(shell pkg-config --cflags gtk+-3.0)
Next, in Project Settings->Linker->Link options, add:

Code: Select all

$(shell pkg-config --libs gtk+-3.0)
Make sure you have read the HOW TO POST thread
jsjs
CodeLite Curious
Posts: 3
Joined: Sun Mar 26, 2017 1:05 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Include GTK libs

Post by jsjs »

Hello,

thank you for the response.
Unfortunately, it did not work for me. I right-clicked on the project in the workspace tab on the left, on settings, in the popup window on compiler, and pasted the exact same code you gave me into C Compiler Options (and C++ Compiler Options), but it didn't change anything. It still says

Code: Select all

gtk/gtk.h not found
and

Code: Select all

make[1]: pkg-config: command not found.
Also, in the Compiler options, there is already written something like that: "

Code: Select all

-g;-O0;-Wall;
". If I type

Code: Select all

$(shell `pkg-config --cflags gtk+-3.0`)
(just to try), it says

Code: Select all

bin/sh: pkg-config: command not found. 
Maybe I have to add that my OS is OS X Sierra (MacOS) and I am using the latest version of Codelite.

I don't know what I did wrong.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Include GTK libs

Post by eranif »

gcc -o main.c base 'pkg-config --cflags gtk+-3.0'
This is what you wrote in your first post, I assumed that you have pkg-config installed and in the path

Try this:
from a Terminal, type:

Code: Select all

which pkg-config
and then, use the full path in CodeLite project settings, so instead of adding line like this:

Code: Select all

$(shell pkg-config --cflags gtk+-3.0)
Add it like this (assuming pkg-config is at /usr/local/bin/pkg-config):

Code: Select all

$(shell /usr/local/bin/pkg-config --cflags gtk+-3.0)
Make sure you have read the HOW TO POST thread
jsjs
CodeLite Curious
Posts: 3
Joined: Sun Mar 26, 2017 1:05 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Include GTK libs

Post by jsjs »

Uh! :o
I love you :D
Didn't know that...Thanks a lot, everything works fine now!
Post Reply