2

Same question goes for gcc, ar, etc. as well.

On changing the toolchain executable from something.exe to x86_64-w64-mingw32-something.exe in Code::Blocks, the code still compiles perfectly. Also, both 32-bit and 64-bit modes work perfectly in both the cases.

g++ -v and x86_64-w64-mingw32-g++.exe -v show the same output on command line.

If these are exactly the same, why are they provided as different executables?

Shubham Avasthi
  • 192
  • 4
  • 16
  • if your program is written in standard c++ you can use any c++ compliant compiler and the code will still compile perfectly, that does not necessarily imply that the compilers are exactly the same – 463035818_is_not_an_ai Sep 20 '17 at 14:13
  • 1
    Did you just compare 2 versions of a compiler on the metric that it compiles code correctly? That would be on the same level of usefulness as comparing 2 cars on the fact that they can drive. – Algirdas Preidžius Sep 20 '17 at 14:14
  • I can't understand how are these executables different. Hence the question. – Shubham Avasthi Sep 20 '17 at 14:15
  • Run them both with `-v` and edit the results into your question. `g++ -v` vs. `x86_64-w64-mingw32-something.exe -v` with no other args shows you some info about how each was configured, and what version of gcc it is. – Peter Cordes Sep 20 '17 at 14:16
  • I am not judging the compilers to be the same. The question asks for what is the difference between the two. – Shubham Avasthi Sep 20 '17 at 14:17
  • Maybe also look at a hello-world.exe from each, and see if they link different libraries or otherwise make different executables. – Peter Cordes Sep 20 '17 at 14:18
  • One might be the default compiler for your system, and the other one for compiling to a specific target. If the "specific target" happens to be the same as the system you are using, they might be identical. Otherwise not. – Bo Persson Sep 20 '17 at 16:10
  • 2
    See https://stackoverflow.com/questions/5731495/can-anyone-explain-the-gcc-cross-compiler-naming-convention on a linux system g++ would most likely by a symbolic link to the __native-native__ version of the compiler. MS Windows does not have convenient symbolic soft links so more than one file is provided. – Richard Critten Sep 20 '17 at 16:26
  • Can you please elaborate @RichardCritten. – Shubham Avasthi Sep 20 '17 at 18:49
  • @ShubhamAvasthi not really unless you have a specific question did you read the link ? – Richard Critten Sep 20 '17 at 20:29
  • Your edit (removing a specific question) made the question less answerable. Or did it turn out that they're *not* the same executable? If they're different, prove it with `md5sum` or something. – Peter Cordes Mar 12 '19 at 13:02
  • @PeterCordes, I understand that inclusion of that question can lead to some people believing that I am (wrongly) equating the compilers based on the fact that they both can compile as is the case in some of the previous comments. By the way, I got the answer to the question. – Shubham Avasthi Mar 12 '19 at 13:14

1 Answers1

3

x86_64-w64-mingw32-g++.exe is a cross compiler, for compiling code that can run on a different type of computer than the one it was compiled on (based on the name, it looks like Windows 64-bit). g++ is the regular compiler, for compiling code to run on the same computer or same type of computer. On your system (e.g. if your system is 64-bit Windows) it's possible that they do the same thing.