C++ 如何在 Windows 7 64 位上设置 MinGw?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14870097/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setup MinGw on Windows 7 64 bit?
提问by Cool_Coder
Before I get any down votes, I would like to say that I am a Mechanical guy with avid interest in C++ programming. Until today I have used VS 2010 Express & Qt Creator to suffice my needs. But now I want to compile Qt Creator in MinGw because the standard SDK is for 32 bit only. I have tried searching for clear instructions on the MinGW wiki, sourceforge, Blogs, etc. But that language is almost understandable for me. I want a Standard C++ Compiler which can Compile 64 as well as 32 bit applications on my Windows 7 64 bit Laptop. Eventually I downloaded
在我得到任何反对票之前,我想说我是一个对 C++ 编程有浓厚兴趣的机械人。直到今天,我一直使用 VS 2010 Express & Qt Creator 来满足我的需求。但是现在我想在 MinGw 中编译 Qt Creator,因为标准 SDK 仅适用于 32 位。我曾尝试在 MinGW wiki、sourceforge、Blogs 等上搜索明确的说明。但这种语言对我来说几乎是可以理解的。我想要一个标准的 C++ 编译器,它可以在我的 Windows 7 64 位笔记本电脑上编译 64 位和 32 位应用程序。最后我下载了
When I extracted it to C:/MinGw64. The targets were like x86_64-w64-mingw32-gcc.exe, x86_64-w64-mingw32-g++.exe. I added them to the PATH Env variable & it compiles my program, but the name is so long. The steps to verify over here: Getting started with OpenCV 2.4 and MinGW on Windows 7
当我将其解压缩到 C:/MinGw64 时。目标类似于 x86_64-w64-mingw32-gcc.exe、x86_64-w64-mingw32-g++.exe。我将它们添加到 PATH Env 变量 & 它编译我的程序,但名称太长。在此处验证的步骤: Windows 7 上的 OpenCV 2.4 和 MinGW 入门
In the correct answer the command is "g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg" but this doesnt work for me. I have to enter "x86_64-w64-mingw32-g++" for compling. Have I done anything wrong? & which do I use to compile 32 bit apps?
在正确答案中,命令是 "g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg" 但是这个对我不起作用。我必须输入“x86_64-w64-mingw32-g++”进行编译。我做错了什么吗?& 我用哪个来编译 32 位应用程序?
Sorry if this is a very stupid question for you guys but I am pretty new to this stuff. Thank You1
对不起,如果这对你们来说是一个非常愚蠢的问题,但我对这些东西很陌生。谢谢你1
采纳答案by Rudi
x86_64-w64-mingw32-g++
is the name of the compiler with the name of the target architecture applied. This is to difference between different versions of gcc on one machine. When you don't have any other gcc installed, you can copy x86_64-w64-mingw32-g++ to g++ and x86_64-w64-mingw32-gcc to gcc.
x86_64-w64-mingw32-g++
是带有应用的目标架构名称的编译器的名称。这是在一台机器上不同版本的 gcc 之间的区别。当您没有安装任何其他 gcc 时,您可以将 x86_64-w64-mingw32-g++ 复制到 g++ 并将 x86_64-w64-mingw32-gcc 复制到 gcc。
You can check if you have other versions of gcc, if you open a terminal (start->run->cmd), and type there gcc -dumpmachine
. If it says something which sounds like a 32bit compiler, you have somewhere the 32bit compiler installed. If it says it is a 64bit compiler, you have nothing to do. If it says there is no gcc, the you have to copy the x86_64-w64-mingw32* compilers and add their path to the system path.
你可以检查你是否有其他版本的 gcc,如果你打开一个终端(开始->运行->cmd),然后在那里输入gcc -dumpmachine
. 如果它说的东西听起来像是 32 位编译器,那么您已经安装了 32 位编译器。如果它说它是一个 64 位编译器,则您无事可做。如果它说没有 gcc,则您必须复制 x86_64-w64-mingw32* 编译器并将其路径添加到系统路径中。