在Windows 10上安装GTk for c? [英] Install GTK for c on Windows 10?

查看:528
本文介绍了在Windows 10上安装GTk for c?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能告诉我如何在Windows 10上安装GTK或获得逐步指南吗,我尝试过的所有方法都没有帮助我. 可能还会有人解释如何从cmd进行编译或准备IDE(可能是代码:可能是块).

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

推荐答案

我提到的任何命令都应在MINGW shell上运行,请在此处找到:C:\msys64\msys2_shell.cmd

Any commands I mention should be run at the MINGW shell, found here: C:\msys64\msys2_shell.cmd

首先使用pacman -Syu

确保已安装GCC ...使用pacman -S mingw-w64-x86_64-toolchain安装GCC所需的工具链.使用pacman时,如果系统提示您继续安装并继续返回命令提示符,请继续输入Enter.

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.

为了使用Code:Blocks进行此设置,请确保转到Code:Blocks菜单设置"->编译器"和工具链可执行文件"菜单.从那里进入msys2安装目录,然后将MinGW的GCC编译器(对我来说是C:\msys64\mingw64)安装在编译器的安装目录选项下.同样,将同一菜单下的C Compiler路径编辑为x86_64-w64-mingw32-gcc.exe.

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.

接下来,为了安装gtk + 3.0,请使用命令pacman -S mingw-w64-x86_64-gtk3.现在将安装最新版本的GTK + 3.0,是时候使用Code:Blocks进行设置了.

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.

打开Code:Blocks并创建一个新的C文件.您肯定可以用Code:Blocks编写代码,但是我不建议您从那里编译它.两次编译,回到MINGW shell.键入nano ~/.bashrc进行编辑.您可以使用箭头键向下滚动到文件底部,然后添加:PATH=$PATH:/c/msys64/mingw64/bin.重新启动MINGW Shell,然后将其备份.

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.

最后,尝试运行:

gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0`.

如果该命令不起作用,建议使用MINGW中安装的i686版本的gcc.

If that command doesn't work, I would suggest using the i686 version of gcc installed in MINGW.

我希望这会有所帮助!

这篇关于在Windows 10上安装GTk for c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆