GTK header files not found when compiling c code in arch linux - c

I am attempting to compile code using the <gtk/gtk.h> header file using gcc. Whenever I do so I get the following error:
gtk.c:3:10: fatal error: gtk/gtk.h: No such file or directory
3 | #include <gtk/gtk.h>
^~~~~~~~~~~
I have looked in /usr/include/ and found gtk-1.2 gtk-2.0 and gtk-3.0 all of which have the header files within them necessary to compile the program I'm unsure why GCC can't find those files and how to reroute gcc to find the necessary header files.

GCC doesn't know which version you want to use. GTK recommends using pkg-config to compile programs. For example, for GTK 3 use:
gcc `pkg-config --cflags gtk+-3.0` yourprogram.c -o yourprogram `pkg-config --libs gtk+-3.0`
You could also specify the correct include and library paths yourself.

Related

C compile error - #include "cmakeconfig.h" - No such file or directory

On a Linux Mint 64bit system using gcc
I'm trying to compile the MiniBrowser example included with the WebKit package that I downloaded. webkitgtk-2.22.3
I have successfully setup the WebKit library, but when I try to compile the Tools/MiniBrowser example I get the error message given in the question title.
NOTE: There is no file on my system called cmakeconfig.h
NOTE: There are a few files called CMakeLists.txt that I do not know what to do with.
NOTE: Compiled using:
gcc `pkg-config --cflags gtk+-3.0 webkit2gtk-4.0 gstreamer-1.0` -o main main.c `pkg-config --libs gtk+-3.0 webkit2gtk-4.0 gstreamer-1.0`
As per the question comments. Use the Linux command cmake with the argument CMakeLists.txt which hopefully will generate the file cmakeconfig.h
$ cmake CMakeLists.txt

What are the proper flags to compile c code using zlib

I'm trying to execute the zpipe.c file from https://zlib.net/zlib_how.html
gcc zpipe.c -o executable -lz
But I'm getting the error
zpipe.c:18:18: fatal error: zlib.h No such file or directory
I installed zlib from source following this tutorial https://geeksww.com/tutorials/libraries/zlib/installation/installing_zlib_on_ubuntu_linux.php
you can use pkg-config.
pkg-config --cflags --libs zlib
Try adding -I/usr/local/include/. It could happen that you have to specify even the library's location with -L/usr/local/lib/.

Type fatal error: gtk/gtk.h: No such file or directory during Eclipse (Oxygen) compilation

I've some errors compiling C code with GTK widgets in Eclipse, indicating that gtk/gtk.h cannot be found. I've already installed GTK+2 and GTK+3; and also included the header paths for GTK but it seems that the Eclipse environment is still unable to find the required header.
Greatly appreciate any advice from the community!
You didn't provide enough information to actually know what is going on, but I guess the include paths you configured are somehow wrong.
My advice would be that you should use pkg-config to obtain the correct compiler flags instead of adding include dirs etc. manually.
This will give you a list of all packages, pkg-config knows are installed on your machine:
pkg-config --list-all
The GTK package should be something like gtk+-3.0
Use this to get the CFLAGS for use with GTK3:
pkg-config --cflags gtk+-3.0
And here is how to get the libraries for the linker stage:
pkg-config --libs gtk+-3.0
So instead of doing something like this:
# Don't do this
gcc -I... main.c
... use something like this:
gcc $(pkg-config --cflags gtk+-3.0) ... main.c
Read the man page of pkg-config for more informations.
There was an Eclipse plugin for pkg-config support, but it doesn't seem to work with Oxygen. I managed to get a building example with these settings, though Eclipse itself won't find the includes.

How to use kplot (Cairo plotting library) without installing it

kplot is a UNIX programming library for plotting graphs on a Cairo surface. The source code is available here.
After downloading the source code I extraced it to the directory kplot-master and cd into it. Simple ls now shows
array.c
border.c
bucket.c
buffer.c
....
example0.c
example1.c
....
I am using Ubuntu 14.04 LTS. Cairo is installed in my system and I tested it by successfully compiling C codes available in [zetcode dot com slash gfx slash cairo slash cairobackends slash] (Sorry as I am not allowed to link more than two).
I am new to GTK and Cairo plotting library and would like help in the following directions:
I do not want to install kplot in my system.
I just want to learn how kplot uses Cairo.
When I use the following command:
gcc example0.c -o example `pkg-config --cflags --libs gtk+-3.0`
it produces the following error message:
example0.c:17:20: fatal error: compat.h: No such file or directory
#include "compat.h"
^
compilation terminated.
It will be very helpful if somebody shows me how to test those kplot examples without installing it.
There is no need to install.
First you will need to compile the kplot library. For that, cd to the kplot directory and run a make command. This will generate the file compat.h. After that you will be able to compile example by example with make example(n) command, or with gcc example(n).c -o example(n) `pkg-config --cflags --libs gtk+-3.0` libkplot.a -lbsd -lm command.
If you have GTK+-3.0 and Cairo dev libraries installed, everything should go well.

DLL: File format not recognised when compiling C with MinGW on Linux for Windows

I'm using MinGW on Linux (Ubuntu, specifically) to compile a C program for Windows. I'm using a library called SFML, and it's bindings called CSFML. I'm using -L and -l to locate the libraries, but when I compile I get this error:
win32/dll/csfml-audio-2.dll: file not recognized: File format not recognised
I've got no idea why. Here's the command I'm using to compile:
sudo i686-w64-mingw32-gcc -o wandering src/main.c src/constants.c src/Display/display.c **...some more c files in here...** src/Generation/perlinnoise.c $(pkg-config --libs --cflags glib-2.0) $(pkg-config --libs --cflags gee-1.0) -Iwin32/CSFML-2.1/include -Lwin32/dll -lcsfml-audio-
Does anyone know why it's happening? I can compile C programs without SFML but with MinGW just fine...
The DLL has a PE32 executable file header. It's not used for the linker. You should use the import library instead. This file has the extension LIB.
I heard there are some gcc compiler versions out there than generate an import library from a DLL on the fly. It looks like your version doesn't.
From command line it seem's trying to use sudo i686-w64-mingw32-gcc 64 bit compiler and supplying 32 bit DLL i.e. win32/dll/csfml-audio-2.dll. change to x64/dll/csfml-audio-2.dll. It should work fine.

Resources