简体   繁体   English

使用MinGW的Windows编程

[英]Windows programming using MinGW

Firstly, please forgive my ignorance regarding these matters, I have done a search and not found any comprehensive answers as of yet. 首先,请原谅我对这些问题的无知,我已经进行了搜索,但尚未找到任何全面的答案。

I plan on learning how to develop for Windows, however I am very fond of the GNU toolchain and don't really want to move onto using big environments like Visual Studio until I feel more comfortable with the underlying basics. 我计划学习如何为Windows开发,但是我非常喜欢GNU工具链,并且在我对基本基础更加满意之前,我并不想真正使用像Visual Studio这样的大型环境。

From what I understand, one can download the Windows SDK, which contains the headers and libraries needed to build native Windows applications. 据我了解,可以下载Windows SDK,其中包含构建本机Windows应用程序所需的标头和库。

Is the SDK literally just a collection of libraries and headers? 从字面上看,SDK只是库和标头的集合吗? If so, as my logic goes, it should be possible to point MinGW towards these libraries/headers, and simply build as normal. 如果是这样,按照我的逻辑,应该可以将MinGW指向这些库/标头,并且只需按正常方式构建即可。

When I build using Visual Studio, I can't see what preprocessor directives are being defined, what is being linked in etc. etc., as I am still learning, I like to be able to know exactly what is going on, preferably so I have to manually define, link etc. Hence the question. 当我使用Visual Studio进行构建时,由于仍在学习中,所以我看不到正在定义哪些预处理程序指令,正在链接的内容等等。我希望能够准确地知道正在发生的事情,最好这样我必须手动定义,链接等。因此出现了问题。

So, what I want to know: is my logic correct? 所以,我想知道的是:我的逻辑正确吗?

Again, apologies if the question is rudimentary, I am still learning. 再次道歉,如果这个问题很基本,我仍在学习。

Ps I am planning to develop Windows applications in a windows environment, this is not a question regarding cross-compilation. 附言:我正计划在Windows环境中开发Windows应用程序,这不是关于交叉编译的问题。

Thanks! 谢谢!

MinGW is not compatible with the official Windows SDK, with one of the reasons MinGW与官方Windows SDK不兼容,原因之一是
being that the SDK contains many VS-specific things (opposed to the GCC base SDK包含许多VS特定的内容(与GCC基本相对)
on MinGW). 在MinGW上)。 MinGW has adapted many of the necessary files, and for many programs MinGW修改了许多必要的文件,并针对许多程序
this is enough. 这就够了。

You don´t need to know the VS project settings for some program; 您无需了解某个程序的VS项目设置;
MinGW is still GCC in the core and used as such. MinGW仍是GCC的核心,因此一直被使用。 If you can compile 如果可以编译
programs with GCC on linux, learning how to use MinGW won´t be hard. 在Linux上使用GCC编写程序,学习如何使用MinGW并不困难。

If you need functions/structures/etc. 如果您需要功能/结构/等。 which are not yet part of it, 还不是它的一部分
you´re out of luck, other than doing the adaption yourself, which 你不走运,除了自己适应,
can be everything between very easy or very hard, depending on the case. 视情况而定,可以是非常容易还是非常困难的一切。
Additionally, proper thread usage is a bit quirky (has some "hidden" pitfalls, 此外,正确使用线程有点古怪(有些“隐藏”陷阱,
which could go unnoticed in an actual program for years, but then...). 多年以来,在实际程序中可能不会引起注意,但是...)。

(While this is a disadvantage to VS, you´ll get C++11/14 (while VS hasn´t (虽然这对VS不利,但是您会得到C ++ 11/14(而VS尚未
even finished with 11, see link ), better optimzation in many cases etc.) 甚至以11结束,请参见link ),在许多情况下优化效果更佳,等等)

If you´re choosing what exactly to download, look at WinGW-W64 instead of 如果要选择要下载的内容,请查看WinGW-W64而不是
the "original" old one. “原始的”旧的。 The original project somewhat stopped, has poor 原来的项目有些停止了,效果很差
lib support compared to W64, no 64bit compiler etc. (and don´t misunderstand 与W64相比,它支持lib,没有64位编译器等。(不要误解
the "W64", it can be used for 32bit programs too) “ W64”,它也可以用于32位程序)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM