I've recently tried installing the gtk library and encountered many problems. Firstly i tried using it on VScode and yet it always shows the same error:
test.c:2:10: fatal error: gtk/gtk.h: No such file or directory
2 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
I've tried configuring c_cpp_properties.json to manually add the paths:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}",
"C:\\msys64\\mingw64\\lib\\**",
"C:\\msys64\\mingw64\\include\\**",
"C:\\msys64\\mingw64\\include\\gtk-3.0",
"C:\\msys64\\mingw64\\include\\gtk-3.0\\gtk",
"C:\\msys64\\mingw64\\include\\glib-2.0",
"C:\\msys64\\mingw64\\include\\pango-1.0",
"C:\\msys64\\mingw64\\include\\harfbuzz",
"C:\\msys64\\mingw64\\include\\cairo",
"C:\\msys64\\mingw64\\include\\gdk-pixbuf-2.0",
"C:\\msys64\\mingw64\\include\\atk-1.0",
"C:\\Users\\Acer\\Code\\vcpkg\\packages\\gtk_x64-windows\\lib",
"C:\\Users\\Acer\\Code\\vcpkg\\packages\\gtk_x64-windows\\include\\gtk-4.0\\**",
"C:\\Users\\Acer\\Code\\vcpkg\\installed\\x64-windows\\lib"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\Hostx64\\x64\\cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
Although the ridicule lenght (beware that i've tried every combination possible of these paths: different order, with more, with less, etc...), these still didn't work.
As you should have noticed i've downloaded gtk via msys64 and vcpkg, the reason being that i then tried running on the Visual Studio IDE, which also didn't work:
E1696: cannot open source file "gtk/gtk.h"
(I thought it might not be recognizing vcpkg path yet changing it still didn't work, neither trying to compile on x64 or x86).
Lastly i tried compiling it myself on gcc:
gcc test.c `pkg-config --cflags --libs gtk+-3.0`
And got the following errors:
gcc.exe: error: pkg-config: No such file or directory
gcc.exe: error: gtk+-3.0`: No such file or directory
gcc.exe: error: unrecognized command line option '--cflags'
gcc.exe: error: unrecognized command line option '--libs'
Changing the command to this variation made it at least give the same error as VSCode:
gcc $(pkg-config --cflags gtk+-3.0) test.c $(pkg-config --libs gtk+-3.0)
I then called pkg-config to see the path that it would show:
pkg-config --cflags --libs gtk+-3.0
-IC:/msys64/mingw64/bin/../include/gtk-3.0 -IC:/msys64/mingw64/bin/../include/pango-1.0 -IC:/msys64/mingw64/bin/../include -IC:/msys64/mingw64/bin/../include/glib-2.0 -IC:/msys64/mingw64/bin/../lib/glib-2.0/include -IC:/msys64/mingw64/bin/../include/harfbuzz -IC:/msys64/mingw64/bin/../include/freetype2 -IC:/msys64/mingw64/bin/../include/libpng16 -mms-bitfields -IC:/msys64/mingw64/bin/../include/fribidi -IC:/msys64/mingw64/bin/../include/cairo -IC:/msys64/mingw64/bin/../include/lzo -IC:/msys64/mingw64/bin/../include/pixman-1 -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -mms-bitfields -IC:/msys64/mingw64/bin/../include/gdk-pixbuf-2.0 -mms-bitfields -mms-bitfields -mms-bitfields -IC:/msys64/mingw64/bin/../include/atk-1.0 -mms-bitfields -mms-bitfields -mms-bitfields -pthread -mms-bitfields -LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
Then tried passing that directly to gcc and got the following error:
On line:1 character:942
+ ... ib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid - ...
+ ~
Argument missing from list of parameters.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument
Wonderful. I then tried adding that to my Path on the system variables. It did not work. Also made sure that all previous paths mentioned before were also there. Nothing works.(Should also mention than other than having multiple gtk+-3.0 installations on my computer one of which is found by pkg-config, i've also installed gtk+-4.0 via vcpkg, this one is not found by pkg-config).
Other than finding out how to finally use gtk on my pc, i would like, if possible, to known what did i do horribly wrong in each of the tries above so that none of them worked.
Thank You.
Related
System: Win10 + Mysy64 + mingw64 + gtk+3.0
When I checked that below are ok as shown below, it seems work well.
pkg-config --cflags gtk+-3.0
C:\msys64>pkg-config --cflags gtk+-3.0
-IC:/msys64/mingw64/bin/../include/gtk-3.0 -IC:/msys64/mingw64/bin/../include/pango-1.0 -IC:/msys64/mingw64/bin/../include -IC:/msys64/mingw64/bin/../include/glib-2.0 -IC:/msys64/mingw64/bin/../lib/glib-2.0/include -IC:/msys64/mingw64/bin/../include/harfbuzz -IC:/msys64/mingw64/bin/../include/freetype2 -IC:/msys64/mingw64/bin/../include/libpng16 -IC:/msys64/mingw64/bin/../include/fribidi -IC:/msys64/mingw64/bin/../include/cairo -IC:/msys64/mingw64/bin/../include/lzo -IC:/msys64/mingw64/bin/../include/pixman-1 -IC:/msys64/mingw64/bin/../include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/bin/../include/atk-1.0 -mms-bitfields
pkg-config --libs gtk+-3.0
C:\msys64>pkg-config --libs gtk+-3.0
-LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
When I try to build below code, errors shown, may I know how to fix it, thank you.
#include <gtk/gtk.h>
int main() {
gtk_init(NULL, NULL);
return 0;
}
Build command in code::blocks:
gcc.exe -LC:\msys64\mingw64 -o bin\Debug\gtk.exe obj\Debug\main.o -LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
||=== Build: Debug in gtk (compiler: GNU GCC Compiler) ===|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__mingw_init_ehandler'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__security_init_cookie'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__security_init_cookie'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_app_type[.refptr.mingw_app_type]+0x0)||undefined reference to `mingw_app_type'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initcharmax[.refptr.mingw_initcharmax]+0x0)||undefined reference to `mingw_initcharmax'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltssuo_force[.refptr.mingw_initltssuo_force]+0x0)||undefined reference to `mingw_initltssuo_force'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdyn_force[.refptr.mingw_initltsdyn_force]+0x0)||undefined reference to `mingw_initltsdyn_force'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdrot_force[.refptr.mingw_initltsdrot_force]+0x0)||undefined reference to `mingw_initltsdrot_force'|
||error: ld returned 1 exit status|
||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|
The build command is generated in code::blocks.
In code::blocks, I set pkg-config --cflags gtk+-3.0 under Compiler setting -> Other compiler options, and pkg-config --libs gtk+-3.0 under Linker setting -> Other linker options. so the build command is combined by these two flags.
pkg-config.exe is a executable which generates --cflags and or --libs for creating a text result which is used for typing all necessary -I and -L and -l flags and libs that are required for compiling with the gcc.exe compiler!
The example code which I am trying to run from command prompt is:
gcc `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`
gcc 'pkg-config --cflags gtk+-3.0' -o hello-world-gtk hello-world-gtk.c 'pkg-config --libs gtk+-3.0'
I get an error which is resulting in an output as follows:
gcc: error: pkg-config: No such file or directory
gcc: error: gtk+-3.0: No such file or directory
gcc: error: pkg-config: No such file or directory
gcc: error: gtk+-3.0: No such file or directory
gcc: error: unrecognized command line option --cflags
gcc: error: unrecognized command line option --libs
ASSUMPTION
I assume that the pkg-config.exe executable is not being found in the location where it is located because of some specific type of Environment Variable which I do not have set or know what its called on the Windows User Environment Variables Settings on my Windows 10 computer since this maybe the reason the gcc.exe which is the current command to run and compile .c files does not have the ability to locate where pkg-config.exe would be located due to a missing Environment Variable.
Does anyone happen to know which Environment Variable it is that I need so that the gcc.exe will know where to locate any other executable which is passed as an argument to the gcc.exe executable?
Environment Variables
GCC_EXEC_PREFIX
COMPILER_PATH
CPATH
gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"
I changed the single quotes to double quotes and it reduced the amount of errors from six errors for the output until and after the new command was executed to two errors which are:
gcc.exe: error: pkg-config.exe --cflags gtk+-3.0: No such file or directory
gcc.exe: error: pkg-config.exe --libs gtk+-3.0: No such file or directory
Any suggestions to the new issue that occurs now after I changed the quotes to a better set of quotes?
I get the error down below when I try to just get the flags Individually from running these commands which are inside the Double quotes Individually and then add them to the command which is below this paragraph:
gcc.exe -mms-bitfields -IC:/gtk_32bit/include/gtk-3.0 -IC:/gtk_32bit/include/cairo -IC:/gtk_32bit/include/pango-1.0 -IC:/gtk_32bit/include/atk-1.0 -IC:/gtk_32bit/include/cairo -IC:/gtk_32bit/include/pixman-1 -IC:/gtk_32bit/include -IC:/gtk_32bit/include/freetype2 -IC:/gtk_32bit/include -IC:/gtk_32bit/include/libpng15 -IC:/gtk_32bit/include/gdk-pixbuf-2.0 -IC:/gtk_32bit/include/libpng15 -IC:/gtk_32bit/include/glib-2.0 -IC:/gtk_32bit/lib/glib-2.0/include -o hello-world-gtk.exe hello-world-gtk.c -LC:/gtk_32bit/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lpangocairo-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
Here is the ERROR I get from running the command above:
gcc.exe: fatal error: cannot execute 'cc1': CreateProcess: No such file or directory
compilation terminated.
This code below should perform the same function as me typing the result from the code below instead of running what is included within the double quotes within the command itself which gives me two errors attempting to do so that's why I tried to do what's above this paragraph instead of what's below this paragraph:
gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"
Here is the ERROR I get from running the command above:
gcc.exe: error: pkg-config.exe --cflags gtk+-3.0: No such file or directory
gcc.exe: error: pkg-config.exe --libs gtk+-3.0: No such file or directory
Here is a link which is what I am trying to accomplish from a command prompt with gcc.exe which is shown in the link with the command above that I am trying to determine how to get the command to work?
https://www.gtk.org/docs/getting-started/hello-world/
So as example is shown in link I am trying to use Command Prompt to compile program above which is the example in the link I provide! I did install everything correctly although the example does not seem to work as shown in the link with the command provided when typing command in CMD.exe console!
gcc.exe "pkg-config.exe --cflags gtk+-3.0" -o hello-world-gtk.exe hello-world-gtk.c "pkg-config.exe --libs gtk+-3.0"
Normally you create a .pc file for pkg-config use it with gcc like in https://en.wikipedia.org/wiki/Pkg-config. You can also use makefiles to create the .pc file (Generate pkg-config out of Makefile)
Makefile : How to install a project with a file pkg-config
This question seems to have been asked a zillion times, but unfortunately, none of the answers helped me.
I believe I have installed gtk correctly. My pkg-config environment seems okay. I'm not so sure of gcc.
I removed all the mingw and cygwin folders from my path environment, as I am only going to be using msys2 packages. So I have my path environment this way:-
GTK_LIB_DIR
C:\msys64\mingw64\lib
PKG_CONFIG_PATH
C:\msys64\mingw64\lib\pkgconfig
Path - C:\msys64\usr\bin;C:\msys64\mingw64\bin;%GTK_LIB_DIR%
The problem I am having is with compilation. Running this...
gcc pkg-config --cflags gtk+-3.0 -o gtkTest C:\dev\test_gtk3.c pkg-config --libs gtk+-3.0
I get...
cc: error: `pkg-config: No such file or directory
gcc: error: gtk+-3.0`: No such file or directory
gcc: error: `pkg-config: No such file or directory
gcc: error: gtk+-3.0`: No such file or directory
gcc: error: unrecognized command line option '--cflags'
gcc: error: unrecognized command line option '--libs'
I can run the following commands separately, with expected results. e.g.
pkg-config --cflags gtk+-3.0
pkg-config --libs gtk+-3.0
gcc -o gtkTest C:\dev\test_gtk3.c
Of course the last command returns an error, since gtk is not referenced.
I tried various combinations, some of my own. Some recommended, but one error persists, on pkg-config.
e.g.
C:\WINDOWS\system32>gcc -o gtkTest C:\dev\test_gtk3.c "pkg-config --cflags gtk+-3.0 pkg-config --libs gtk+-3.0"
gcc: error: pkg-config --cflags gtk+-3.0 pkg-config --libs gtk+-3.0: No such file or directory
The last answer I found says "If pkg-config reports that it couldn't find the package, then you didn't install the Gtk development package as offered by your Linux distribution."
I'm using Windows, but I think I installed gtk correctly, since I followed the instructions, and I get what seems to be the expected results (please correct me if I am mistaken).
C:\WINDOWS\system32>pkg-config --cflags gtk+-3.0
-pthread -mms-bitfields -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/m
ingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/fribidi -I/mingw6
4/include -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include
/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/
mingw64/include/harfbuzz -I/mingw64/include -I/mingw64/include/libpng16 -I/mingw
64/include/gdk-pixbuf-2.0 -I/mingw64/include -I/mingw64/lib/libffi-3.2.1/include
-I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include
C:\WINDOWS\system32>pkg-config --libs gtk+-3.0
-L/mingw64/lib -L/mingw64/lib/../lib -L/mingw64/lib -lgtk-3 -lgdk-3 -lz -lgdi32
-limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lep
oxy -lopengl32 -lgdi32 -lpangocairo-1.0 -lm -lgdi32 -lpangoft2-1.0 -lm -lpangowi
n32-1.0 -lm -lusp10 -lgdi32 -lpango-1.0 -lm -lfribidi -lthai -ldatrie -latk-1.0
-lcairo-gobject -lcairo -lz -lpixman-1 -lm -pthread -lfontconfig -liconv -lexpat
-lfreetype -lbz2 -lharfbuzz -lm -lusp10 -lgdi32 -lrpcrt4 -lgraphite2 -lpng16 -l
z -lgdk_pixbuf-2.0 -lm -lgio-2.0 -pthread -lintl -lshlwapi -ldnsapi -liphlpapi -
lws2_32 -lgmodule-2.0 -pthread -lintl -lz -lgobject-2.0 -pthread -lintl -lffi -l
glib-2.0 -lintl -lws2_32 -lole32 -lwinmm -lshlwapi -pthread -lm -lpcre
C:\WINDOWS\system32>gcc -o gtkTest C:\dev\test_gtk3.c | pkg-config --cflags --libs gtk+-3.0
-pthread -mms-bitfields -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/m
ingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/fribidi -I/mingw6
4/include -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include
/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/
mingw64/include/harfbuzz -I/mingw64/include -I/mingw64/include/libpng16 -I/mingw
64/include/gdk-pixbuf-2.0 -I/mingw64/include -I/mingw64/lib/libffi-3.2.1/include
-I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include
-L/mingw64/lib -L/mingw64/lib/../lib -L/mingw64/lib -lgtk-3 -lgdk-3 -lz -lgdi32
-limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lep
oxy -lopengl32 -lgdi32 -lpangocairo-1.0 -lm -lgdi32 -lpangoft2-1.0 -lm -lpangowi
n32-1.0 -lm -lusp10 -lgdi32 -lpango-1.0 -lm -lfribidi -lthai -ldatrie -latk-1.0
-lcairo-gobject -lcairo -lz -lpixman-1 -lm -pthread -lfontconfig -liconv -lexpat
-lfreetype -lbz2 -lharfbuzz -lm -lusp10 -lgdi32 -lrpcrt4 -lgraphite2 -lpng16 -l
z -lgdk_pixbuf-2.0 -lm -lgio-2.0 -pthread -lintl -lshlwapi -ldnsapi -liphlpapi -
lws2_32 -lgmodule-2.0 -pthread -lintl -lz -lgobject-2.0 -pthread -lintl -lffi -l
glib-2.0 -lintl -lws2_32 -lole32 -lwinmm -lshlwapi -pthread -lm -lpcre
C:\dev\test_gtk3.c:1:10: fatal error: gtk/gtk.h: No such file or directory
1 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
compilation terminated.
Has anyone here struggled with this for hours, like I have, and finally got to understand what the problem is.
Please share your solution. Thank you.
Using this Installing gtk and compiling using gcc under windows? helped me get past the errors.
I used the following suggestion.
"Instead of a batch file, you may find more convenient to create an
user environmental variable and store the flags in there, that way you
will be able to compile from within a normal command prompt."
So I created two new environment variables (e.g. GTK_FLAGS_VARS; GTK_LIBS_VARS), and pasted the outputs in the variable values. Then in path place %GTK_FLAGS_VARS%;%GTK_LIBS_VARS%
Afterward gcc -o gtkTest C:\dev\test_gtk3.c %GTK_FLAGS_VARS% %GTK_LIBS_VARS%
I'm new at C and started to learn how to create GUI.
For some reason the only way program run is
gcc simple.c -o simple -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12
If i just run gcc simple.cit gives me
In file included from /usr/include/glib-2.0/glib/galloca.h:32:0,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-2.0/gdk/gdk.h:32,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from graphical.c:1:/usr/include/glib-2.0/glib/gtypes.h:32:24: fatal error: glibconfig.h: No such file or catalog compilation terminated.
If I do other 'traditional' ways to include lib:
gcc `pkg-config gtk+-2.0 --cflags` example.c -o example `pkg-config gtk+-2.0 --libs`
It gives me:
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
graphical.c:1:21: fatal error: gtk/gtk.h: No such file or catalog
What is the right way to include GTK?
I just figured out what was the problem.
I had linuxbrew installed and for some reason pkg-config took path from one of it's repos even if I force it to export.
I completely removed linuxbrew and now it's finally working!
I'm trying to compile a C program using GTK+ in bloodshed Dev-C++ 4.9.9.2.
I've added all the include files in the compiler options plus all compiler options, but I get the following error:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Projects\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Projects\Makefile.win" all
gcc.exe main.o -o "MyCProject.exe" -L"C:/Dev-Cpp/lib" -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lgdk_pixbuf-2.0 -lcairo -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -lfreetype -lzdll -lfontconfig -lpng13 -lpangocairo-1.0
C:\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe: cannot find -lintl
collect2: ld returned 1 exit status
make.exe: *** [MyCProject.exe] Error 1
Execution terminated
Can someone help me with what '-lintl' is and if it's a package missing or some file?
LibIntl
http://gnuwin32.sourceforge.net/packages/libintl.htm
You can get devpak from HERE
Aside:
I don't think Dev-C++ has been updated in years. Have you considered moving to Code::Blocks