LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2021, 10:38 AM   #1
bcsm
LQ Newbie
 
Registered: Jul 2021
Distribution: Mint 21 (Thinkpad x270) / Debian 11 (PC) / Ubuntu 22.04 (Surface 3)
Posts: 12
Blog Entries: 1

Rep: Reputation: Disabled
"<gtk/gtk.h> not found" when trying to compile C GTK program.


Hi,

I'm on Linux Mint 20.2 Cinnamon, and I have libgtk-3-0 (already present by default) and libgtk-3-dev (via apt on command line) installed. gtk-3.0 is present in usr/include, with gtk, gdk and unix-print folders present inside.

When trying to compile a C program with an empty main() function and the only #include being <gtk/gtk.h>, this error is thrown: "fatal error: gtk/gtk.h: No such file or directory".

I made some progress by doing "#include <gtk-3.0/gtk/gtk.h>", however this just gave this error instead, in gtk.h: "/usr/include/gtk-3.0/gtk/gtk.h:30:10: fatal error: gdk/gdk.h: No such file or directory"

I'm using geany to edit, but using cc and gcc at command line produced the same errors.

How can I fix this? Thank you
 
Old 07-25-2021, 11:09 AM   #2
EdGr
Senior Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,002

Rep: Reputation: 473Reputation: 473Reputation: 473Reputation: 473Reputation: 473
Use pkg-config to generate a list of include paths and libraries. See https://developer.gnome.org/gtk3/sta...compiling.html.

As an alternative, autoconf can do all of this for you. Add:

Code:
PKG_CHECK_MODULES(PACKAGE, [
  gtk+-3.0 >= 3.24.0
])
to your configure.ac.
Ed
 
1 members found this post helpful.
Old 07-25-2021, 11:11 AM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
Do you have those header files on your machine?
On this arch machine they are at
Code:
/usr/include/gtk-2.0/gtk/gtk.h
/usr/include/gtk-3.0/gtk/gtk.h

/usr/include/gtk-2.0/gdk/gdk.h
/usr/include/gtk-3.0/gdk/gdk.h
 
1 members found this post helpful.
Old 07-25-2021, 11:25 AM   #4
EdGr
Senior Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,002

Rep: Reputation: 473Reputation: 473Reputation: 473Reputation: 473Reputation: 473
Quote:
Originally Posted by teckk View Post
Do you have those header files on your machine?
Yes, but locations may differ. On Slackware:

Code:
% pkg-config --cflags gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
Ed
 
1 members found this post helpful.
Old 07-25-2021, 12:28 PM   #5
bcsm
LQ Newbie
 
Registered: Jul 2021
Distribution: Mint 21 (Thinkpad x270) / Debian 11 (PC) / Ubuntu 22.04 (Surface 3)
Posts: 12

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thank you both! Managed to get it working using link provided by EdGr: https://developer.gnome.org/gtk3/sta...compiling.html

For anyone having the same problem who is new to all of this like me, you can set what the command Geany uses to build the program by going to Build > Set Build Commands, to save you writing it all out on the command line every time. This is what it ended up being for me (for Build, not Compile) gcc "%f" -Wall -o "%e" `pkg-config --cflags --libs gtk+-2.0`

For reference, I did have the header files in the location teckk provided.

Last edited by bcsm; 07-25-2021 at 12:31 PM. Reason: Added build command
 
  


Reply

Tags
c programming, gtk



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
[SOLVED] complete noob question. "command not found" "command not found" jeanlucpicard Linux - Newbie 4 08-27-2013 02:14 AM
Trying to compile kde 3.4.2 on Etch. Problem: kde-config program not found Yury Debian 4 03-30-2010 04:32 PM
Slack64; trying to compile libparted = "error: GNU Readline could not be found" GrapefruiTgirl Linux - Software 9 01-26-2010 12:30 PM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration