I wanted to create a GUI program using C and GTK. I am using a windows operating system, so I had followed the instructions from the GTK Windows installation page. However, when trying to compile my program using:
gcc main.c -o main.exe `pkg-config --cflags --libs gtk4`
I had the following errors:
gcc.exe: error: pkg-config: No such file or directory
gcc.exe: error: gtk4`: No such file or directory
gcc.exe: error: unrecognized command-line option '--cflags'
gcc.exe: error: unrecognized command-line option '--libs'
I noticed that the command pkg-config --cflags --libs gtk4
was actually returning a list of required includes. It seemed that the gcc command simply was not able to recognize them. To solve the problem, I then created a Makefile, in which a variable called GTK_4_INCLUDES
contains the list of includes.
The compilation command becomes:
gcc main.c -o main.exe $(GTK_4_INCLUDES)
To compile the program in the console, I just had to type mingw32-make
, and I was able to execute the resulting compiled file. Done!
Comments
Post a Comment