Daniel8
December 28, 2021, 10:13pm
1
gcc main.c -o executable.exe ` pkg-config --cflags --libs gtk+-3.0 `
main.c:5:10: fatal error: gtk/gtk.h: No such file or directory
5 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
compilation terminated.
I have tried this mingw64.exe , but the results are the same as above.
ebassi
(Emmanuele Bassi)
December 28, 2021, 10:15pm
2
The correct command line is:
gcc -Wall `pkg-config --cflags gtk+-3.0` -o executable.exe main.c `pkg-config --libs gtk+-3.0`
You’re placing the backticks ` in the wrong order.
You can also use $( )
:
gcc -Wall $( pkg-config --cflags gtk+-3.0 ) -o executable.exe main.c $( pkg-config --libs gtk+-3.0 )
Daniel8
December 28, 2021, 10:19pm
3
gcc: error: unrecognized command-line option '--cflags'
gcc: error: unrecognized command-line option '--libs'
I have tried your command but was given the error above.
ebassi
(Emmanuele Bassi)
December 28, 2021, 10:20pm
4
What happens when you try pkg-config
by itself?
Daniel8
December 28, 2021, 10:21pm
5
Please specify at least one package name on the command line.
That’s the results I got when I tried your command pkg-config
ebassi
(Emmanuele Bassi)
December 28, 2021, 10:23pm
6
Then you’re writing the command line for GCC wrong. If you’re getting:
it means you’re passing --cflags
and --libs
to GCC, instead of passing them to pkg-config and using pkg-config’s output with GCC.
Since you’re not using a build system, you can also copy the output of:
pkg-config --cflags gtk+-3.0
to get the compiler flags, and:
pkg-config --libs gtk+-3.0`
to get the linker flags.
Daniel8
December 28, 2021, 10:28pm
7
I have alredy tried to add the
pkg-config --cflags gtk+-3.0
pkg-config --libs gtk+-3.0
to codeblocks. But
G:\document\C++C\gtkCode\main.c|5|fatal error: gtk/gtk.h: No such file or directory|.
Actually, I can find the gtk.h in mingw64/include/gtk-3.0 . But I don’t know why it fails to do so.
MichiB
(Michael Buzgaru)
December 29, 2021, 5:02pm
8
Open CMD and tell us what returns the following command:
pkg-config --modversion gtk+-3.0
Daniel8
December 29, 2021, 9:38pm
9
G:\document\C++C\gtkCode>pkg-config --modversion gtk+-3.0
3.24.30
That’s what I got from your command.
MichiB
(Michael Buzgaru)
December 30, 2021, 6:31pm
10
Then you are doing something wrong there. Emmanuele gave you some Hints.
Daniel8
December 30, 2021, 8:34pm
11
What results do you expect? I don’t understand his hints. Copy pkg-config --cflags gtk+-3.0
output to to where?
PeterB
(Peter Bloomfield)
December 30, 2021, 8:39pm
12
Did you try the first command line that @ebassi suggested? Perhaps your gcc
is sensitive to the order of its arguments.
Daniel8
December 30, 2021, 9:01pm
13
I have tried. But where should I put the output?
Daniel8
December 30, 2021, 9:02pm
14
I have tried. But where should I put the output?
greg-king
(Greg King)
December 31, 2021, 5:25am
15
You did not type the backticks! Without those backticks, the word pkg-config
was seen as an ordinary file-name; it wasn’t seen as a command. Because of that problem, the words that followed it, --cflags
and --libs
, looked as though they belonged to gcc. Of course, they don’t; therefore, gcc complained.
When you type @ebassi ’s command again, make sure that you type all of the backticks – there are four of them on that line. Make sure that you type them exactly where he typed them.
Daniel8
December 31, 2021, 8:45am
16
Nope, I added backticks. The reason why it’s no displayed properly it’s because it’s recognized as code blocks in this website format. Finally, I manged to fix this issue with backslashes \ as prefixes before baclticks `
G:\document\C++C\gtkCode>gcc -Wall `pkg-config --cflags gtk±3.0` -o executable.exe main.c `pkg-config --libs gtk±3.0`
gcc: error: unrecognized command-line option ‘–cflags’
gcc: error: unrecognized command-line option ‘–libs’
greg-king
(Greg King)
December 31, 2021, 12:43pm
17
That looks like Windows’ command prompt. Backticks don’t work in cmd.exe! “$( )” also doesn’t work. In cmd.exe, they’re ordinary punctuation characters.
You must go into MSys2, navigate to /g/document/C++C/gtkCode
, and enter the command there.
jack@DESKTOP-RDDFVF2 MINGW64 /g/document/C++C/gtkCode
gcc -Wall `pkg-config --cflags gtk±3.0` -o executable.exe main.c `pkg-config --libs gtk±3.0`
main.c:5:10: fatal error: gtk/gtk.h: No such file or directory
5 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
compilation terminated.
I execute this mingw64
MichiB
(Michael Buzgaru)
January 1, 2022, 10:04pm
19
Why are you using ±
between gtk
and 3.0
?
This is a format issue which was caused by this website. I really don’t know how to fix this on this website. I have tried to use backslash \ to fix. But this is not working.