Install GTK for c on Windows 10?

Deadly 提交于 2019-12-25 02:46:33

问题


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).


回答1:


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!



来源:https://stackoverflow.com/questions/37737020/install-gtk-for-c-on-windows-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!