简体   繁体   English

无法在Windows 7、32位上使用tdm-gcc构建cpp文件(说exe不兼容)

[英]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. 环境和我要执行的操作:我试图在32位 Windows 7 PC上设置带有sublime text 3的C ++编码/调试环境。

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). 我安装了Windows和Dev-C ++的Sublime Text 3(来自http://orwelldevcpp.blogspot.kr/ ),其中包括TDM-GCC 4.9.2(32位和64位)。

Problem: After adding "C:\\Program Files\\Dev-Cpp\\MinGW64\\bin" to the PATH environment variable, I tried to build a simple Hello World! 问题:在将“ C:\\ Program Files \\ Dev-Cpp \\ MinGW64 \\ bin”添加到PATH环境变量后,我尝试构建一个简单的Hello World! code, but only got this messege: 代码,但只有这样:

[Finished in 5.1s with exit code 1] [在5.1s中完成,退出代码为1]

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

[dir: D:\\SublimeText] [dir:D:\\ SublimeText]

[path: (all the directories added to PATH)] [路径:(将所有目录添加到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. 当我尝试执行D:\\ SublimeText中生成的main.exe文件时,出现警告,例如“此程序与此操作系统不兼容。 Check your OS type if it's 32 bit or 64 bit and execute the right one'. 检查您的操作系统类型是32位还是64位,然后执行正确的操作。

If I compile and run the same code in Dev-C++ after choosing the 'TDM-GCC 32bit compiler', it compiles and runs just fine. 如果选择“ TDM-GCC 32位编译器”后在Dev-C ++中编译并运行相同的代码,则它可以编译并运行良好。

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. 预期的原因: Sublime Text可能使用64位编译器编译我的代码,但是我找不到如何使用32位编译器进行编译的代码。

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. TDM GCC 64位编译器可以在32位主机(如您的主机)上安装和运行,因为编译器可执行文件本身都是32位的。

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. 64位编译器可以为您生成64位和32位可执行文件,默认情况下将生成64位可执行文件,这些文件将无法在32位主机上运行。 To get 32-bit executables you must explicitly tell gcc you want them by passing it the -m32 option, for both compilation and linkage. 要获取32位可执行文件,您必须通过将-m32选项传递给gcc来明确告知您想要的gcc,以便进行编译和链接。

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

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