安装GTK和Windows下使用gcc编译? [英] Installing gtk and compiling using gcc under windows?
问题描述
我已经安装在c GCC:/ PROGRAMFILES(也设置为路径变量),我都从的 http://www.gtk.org/download-windows.html ,巧舌如簧,GTK和Pango,ATK和开罗。虽然我没有线索如何编译使用GTK用gcc编译的C程序。我如何设置好一切,这样它的工作原理? (我不知道每个zip文件中去?)基本上我真的不知道从哪里开始。
I have gcc installed in c:/programfiles (also set as a path variable), and i have all the necessary files for gtk from http://www.gtk.org/download-windows.html, glib,gtk,pango,atk and cairo. Although I have no clue as to how to compile a c program using gtk with the gcc compiler. How do I set everything up so that it works?. (I don't know where each zip file goes.?) basically I don't really know where start.
推荐答案
好吧,安装和在Windows中使用GTK +和使用它的MinGW就可以按照这些步骤的例子。我会尽力让他们轻松,不用担心:
Ok, to install and use GTK+ in Windows and use it with MinGW you may follow these steps for example. I'll try to made them the easy, don't worry:
- 安装MinGW的,因为你已经做到了,所以我不会详细说明此步骤。
- 下载 GTK +的所有功能于一身的包(有可能的事情你可能不使用...但这种方式应该工作)。
- DECOM preSS包的内容,你可以做它在安装MinGW的同一文件夹或做它在另一个文件夹,也没关系。
-
启动命令提示符下,获取到
斌
目录在解包和运行:
- Install MinGW, as you've already done it so I wont elaborate this step.
- Download the GTK+ all-in-one bundle (there may be things you may not use... but this way should work).
- Decompress the contents of the bundle, you may do it in the same folder MinGW is installed or do it in another folder, it doesn't matter.
Launch a command prompt, get to the
bin
directory where you extracted the bundle and run:
pkg配置--cflags --libs GTK + -win32-2.0
这将打印编译标志的列表和库到您的项目链接。现在,将它们复制并创建以下的批处理文件(.bat或Windows命令脚本的.cmd):
It will print a list of compilation flags, and libraries to link your project to. Now, copy them and create a batch file (.bat or Windows Command Script .cmd) with the following:
组VAR = FLAGS
启动CMD
其中, VAR
是一个变量(例如GTK)的名称,而 FLAGS
是$输出p $ pvious指令( pkg配置
)。
Where VAR
is a name of a variable (for example GTK) and FLAGS
is the output of the previous command (pkg-config
).
当你想要的东西编译使用GTK +双击该文件,GTK +的旗帜将在 VAR
。你可以编译这种方式,例如:
Whenever you want to compile something that uses GTK+ double click that file, the GTK+ flags will be in VAR
. You may compile this way for example:
GCC的foo.c%VAR%
而不是一个批处理文件,你可能会发现更方便地创建一个用户环境变量和标志存储在那里,这样你就可以从一个正常的命令提示符中进行编译。我没有描述,由于办法做到这一点取决于Windows版本你有。一般来说,你会发现它在先进的系统性能。
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. I didn't describe that because the way to do it varies depending on the version of Windows you have. Generally you may find it in advanced system properties.
一旦你在GTK +更加自信编程您可能无法使用所有的软件包,或所有的标志,或以不同的方式重新排序,使用,而无需编译标志,并在一个环境变量的库的makefile。 ..
Once you are more confident in GTK+ programming you may not use all of the packages, or all the flags, or reorder them in a different manner, use makefiles instead of having the compilation flags and the libraries in an environmental variable, ...
但现在,这将让你开始。
But by now, this will get you started.
此外,你可以动态链接到GTK +,所以无论是正确的库在项目的同一个目录或者从路径访问,当你想运行它。
Also, you'll be linking dynamically to GTK+, so either the proper libraries are in the same directory of your project or are accessible from the path when you want to run it.
这篇关于安装GTK和Windows下使用gcc编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!