6

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

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/mingw-w32-bin_i686-mingw_20111219.zip/download

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

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?

Sorry if this is a very stupid question for you guys but I am pretty new to this stuff. Thank You1

Community
  • 1
  • 1
Cool_Coder
  • 4,888
  • 16
  • 57
  • 99
  • To compile 64-bit apps in VC++2010 you should download correct image from http://www.microsoft.com/en-us/download/details.aspx?id=8442. Select - x64 ISO File Name: GRMSDKX_EN_DVD.iso. Read this blog for help http://blogs.msdn.com/b/windowssdk/archive/2010/05/25/released-windows-sdk-for-windows-7-and-net-framework-4.aspx – SChepurin Feb 14 '13 at 08:01
  • I didn't end up using MinGW, but I went through basically the same thing to get 64-bit with Qt on Windows--go through my recent questions and see, it may help you. – Matt Phillips Feb 14 '13 at 08:02
  • Although it's for eclipse you might want to check this post http://stackoverflow.com/questions/17393311/openvc-2-4-5-eclipse-cdt-juno-mingw-error-0xc0000005/17402441#17402441 – Nenad Bulatović Jul 01 '13 at 11:25

1 Answers1

6

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.

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.

Rudi
  • 19,366
  • 3
  • 55
  • 77
  • I am getting: 'gcc' is not recognized as an internal or external command, operable program or batch file. – Cool_Coder Feb 14 '13 at 08:54
  • Then everything looks fine. Just copy the compilers to gcc.exe and g++.exe, and add the directory to your PATH environment variable (http://www.computerhope.com/issues/ch000549.htm) and probably restart windows. – Rudi Feb 14 '13 at 09:33
  • ya that works! but it works only for command g++. for gcc it shows 5 errors: undefined reference to `std::basic_istream >::operator>>(int& )' & more such. My cpp file only prints hello world & pauses to take user input. – Cool_Coder Feb 14 '13 at 09:53
  • 1
    The error comes from the link stage. Either you run g++ as linker, or add `-lstdc++` to the linker parameters of gcc. – Rudi Feb 14 '13 at 13:34
  • This depends on how your software is build. Can you post the buildlog on pastebin.com? – Rudi Feb 14 '13 at 14:31
  • I didnt build MinGW myself. I downloaded the automated build from sourceforge. – Cool_Coder Feb 15 '13 at 10:28