简体   繁体   English

代码::具有MinGW链接的块失败

[英]Code::Blocks with MinGW linking fail

I am using Code::Blocks (ver. 13.12) with MinGW (ver. 4.7.1) on 32-bit Windows 7. 我在32位Windows 7上将Code :: Blocks(13.12版)与MinGW(4.7.1版)配合使用。

While trying to build my project I get the following error after the compilation step: 尝试构建我的项目时,在编译步骤后出现以下错误:

Execution of 'mingw32-g++.exe  -o cb_dlv.exe
...huge list of *.o files...
in 'D:\Workspace\cb_dlv' failed.

There's certainly no problem with toolchain executables as my other projects compile and link pretty well and all the tools are in their right places. 工具链可执行文件当然没有问题,因为我的其他项目可以很好地进行编译和链接,并且所有工具都位于正确的位置。 mingw32-g++.exe is seen from cmd so no problems with PATH variable. cmd可以看到mingw32-g++.exe ,因此PATH变量没有问题。 Cleaning workspace also doesn't seem to help in any way. 清理工作空间似乎也无济于事。 I've already tried to move project files so that the path has no spaces in it, but it didn't help either. 我已经尝试过移动项目文件,以便该路径中没有空格,但这也无济于事。 As well as reopening/reinstalling/rebooting. 以及重新打开/重新安装/重新启动。

Any suggestions? 有什么建议么?

Since I've found the solution, here it is. 既然找到了解决方案,就可以了。

The main problem was that on Windows 7, the limit for the length of a command line is around 32K characters. 主要问题是在Windows 7上,命令行长度的限制约为32K个字符。 MinGW compiler and linker hit that limit while building projects with huge amount of files in them. MinGW编译器和链接器在构建包含大量文件的项目时达到了该限制。 This is a fundamental limitation of Windows APIs that MinGW uses. 这是MinGW使用的Windows API的基本限制。

The solution: shorten the command line in any way you like: merge some files in one, separate project into several ones, rename subdirectories with long names, etc. 解决方案:以您喜欢的任何方式缩短命令行:将一些文件合并到一个文件中,将项目分成多个文件,使用长名称重命名子目录,等等。

Have you set your project to use a custom makefile? 您是否已将项目设置为使用自定义生成文件? What are your build system variables? 您的构建系统变量是什么? Are the object files available in D:\\Workspace\\cb_dlv? 目标文件在D:\\ Workspace \\ cb_dlv中可用吗? Is that the only output of your compile log or is there other output before it? 那是您的编译日志的唯一输出,还是在它之前还有其他输出? are your project's build targets set up sensibly? 您项目的构建目标是否合理设置?

you should see the build system log that it is compiling your c/c++ files to object files before the last linking stage happens ie stuff like: 在最后一个链接阶段发生之前,您应该看到生成系统日志,它正在将c / c ++文件编译为目标文件,例如:

mingw32-g++.exe -c D:\Workspace\cb_dlv\file.c -o D:\Workspace\cb_dlv\obj\Debug\file.o

Please flesh out this question some more and I might be able to help you. 请进一步完善这个问题,我可能会为您提供帮助。

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

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