简体   繁体   中英

Cannot build cpp file with tdm-gcc on windows 7, 32bit(says exe is not compatible)

Environment and What I'm Trying to Do: I'm trying to set up a C++ coding/debugging environment with sublime text 3 on a 32 bit Windows 7 PC.

I installed Sublime Text 3 for Windows and Dev-C++(from http://orwelldevcpp.blogspot.kr/ ) which includes TDM-GCC 4.9.2 (32bit and 64bit).

Problem: After adding "C:\\Program Files\\Dev-Cpp\\MinGW64\\bin" to the PATH environment variable, I tried to build a simple Hello World! code, but only got this messege:

[Finished in 5.1s with exit code 1]

[shell_cmd: g++ "D:\\SublimeText\\main.cpp" -o "D:\\SublimeText/main" && "D:\\SublimeText/main"]

[dir: D:\\SublimeText]

[path: (all the directories added to PATH)]

When I try to execute the main.exe file generated in D:\\SublimeText, a warning that says something like 'This program is not compatible with this OS. Check your OS type if it's 32 bit or 64 bit and execute the right one'.

If I compile and run the same code in Dev-C++ after choosing the 'TDM-GCC 32bit compiler', it compiles and runs just fine.

Expected Cause: Maybe Sublime Text compiles my code with a 64bit compiler, but I couldn't find how to make it use the 32bit compiler.

I'm new to coding(registered to stack overflow an hour ago..), so a kind and detailed answer would be very appreciated! Thank You.

The TDM GCC 64 bit compiler can be installed and run on a 32-bit host (like yours) because the compiler executables are themselves all 32-bit.

The 64-bit compiler can generate both 64- and 32-bit executables for you, and by default will generate 64-bit ones, which will not run on your 32-bit host. To get 32-bit executables you must explicitly tell gcc you want them by passing it the -m32 option, for both compilation and linkage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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