Can you tell me how to install GTK on windows 10 or have a step by step guide, all the ones I've tried have not helped me. Possibly if someone also explain how to compile from cmd or prepare an IDE (code: block maybe).
-
1The step by step guide for installing MSYS2 and installing packages on MSYS2 is https://msys2.github.io/. Once you have that set up, do a `pacman -Ss gtk` and you should find the correct packages for GTK+. `pacman -Ss gcc` for gcc, which you build from the command line with; there are lots of tutorials from that point on. Good luck! – andlabs Jun 09 '16 at 22:37
-
how do i create and compile a file? – Pegasum Jun 09 '16 at 23:29
1 Answers
Any commands I mention should be run at the MINGW shell, found here: C:\msys64\msys2_shell.cmd
First update msys2 with pacman -Syu
Make sure you have installed GCC...Install the required toolchain for GCC with pacman -S mingw-w64-x86_64-toolchain
. When using pacman, just keep typing enter if prompted to follow through with the installation and get back to the command prompt.
In order to set this step up with Code:Blocks, make sure you go to the Code:Blocks menu Settings->Compiler, and the menu Toolchain Executables. From there, put in the msys2 installation directory and where you installed MinGW's GCC compiler (for me this was putting C:\msys64\mingw64
) under the compiler's installation directory option. Also edit the C Compiler
path under the same menu to x86_64-w64-mingw32-gcc.exe
.
Next, in order to install gtk+3.0, use the command pacman -S mingw-w64-x86_64-gtk3
. Now the latest version of GTK+3.0 will have been installed, so it is time to set it up with Code:Blocks.
Open Code:Blocks and create a new C file. You may definitely write your code in Code:Blocks, but I do not suggest that you compile it from there. Two compile, go back to the MINGW shell. Type nano ~/.bashrc
to edit it. You may scroll down using the arrow keys to the bottom of the file and add: PATH=$PATH:/c/msys64/mingw64/bin
. Restart the MINGW shell and open it back up.
Finally, try running:
gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0`.
If that command doesn't work, I would suggest using the i686 version of gcc installed in MINGW.
I hope this helps!

- 562
- 1
- 9
- 19
-
after i create file.exe, when i run it cliking on icon it give me an error : impossible running the program because msys-gcc_c.dll is not present in the computer. For resolve the problem try a re-install the program. But if i run it from the terminal works.. how do i export it to another pc ? – Pegasum Jun 10 '16 at 13:57
-
@Pegasum: You put all the required DLLs in the same folder as the executable. – David Grayson Jun 10 '16 at 15:22
-
Yes, @DavidGrayson is right. Do _not_ try to statically link the libraries, or else that might just lead to a mess. I'm glad my answer helped you. – iRove Jun 10 '16 at 17:16
-
Any dlls you will need to include will probably be in C:\msys64\mingw64\bin or in C:\msys64\usr\bin. – iRove Jun 10 '16 at 18:45
-
How can i configure code-block? The guides it don't work.. i inserted "pkg-config --cflags --libs gtk+-2.0" in setting>compiler>other options.. – Pegasum Jun 10 '16 at 20:29
-
Try adding `\`pkg-config --cflags gtk+-3.0\`` to your compiler other settings and `\`pkg-config --libs gtk+-3.0\`` to your linker other settings. However, if that doesn't work I suggest you compile from the command line (MINGW shell) even if you write the code in Code:Blocks – iRove Jun 10 '16 at 21:54
-
it doesn't work.. there is an ide on windows per development gtk in c? – Pegasum Jun 11 '16 at 01:18
-
There are a few options out there for Linux, and I strongly suggest you develop on Linux. If you have a Windows machine, look up on installing virtual box (which allows you to run other OSs like a Linux distribution) to run an OS like Ubuntu GNOME. Do research on GTK IDEs, like Glade or GNOME builder to install on your virtual machine. You should develop on a Linux platform first, and then port to Windows. GTK is native to Linux, and quote honestly, it doesn't have great Windows support. It is meant for you to start at Linux and _then_ port to Windows. – iRove Jun 11 '16 at 02:49
-
Expanding upon my previous comment, I suppose there is nothing wrong with developing with GTK on windows. I simply feel like it will be easier for anyone still learning GTK (but maybe you are familiar with the platform; I am not sure). If you are looking for an IDE with graphical design capabilities, then I suggest starting with Linux. However, you can just as easily develop without it, in which case, using Windows is perfectly fine. You may use your favorite Windows text editor to write the code, whether it be notepad++, vim, emacs, etc. and simply compile from the command line. – iRove Jun 11 '16 at 05:01