在Windows命令提示符下链接.obj文件时,“命令行太长” [英] 'The command line is too long' when linking .obj files in Windows command prompt

查看:63
本文介绍了在Windows命令提示符下链接.obj文件时,“命令行太长”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我在Windows上进行Maven构建的最后一步,它尝试通过链接约1500个目标文件来创建 dll 文件。看起来像这样:

As a last step to my maven build on Windows, it tries to create a dll file by linking around 1500 object files. Looks something like this:

cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

仅用以下一条语句即可构建失败:
命令行太长了。

The build fails with just one statement: The command line is too long.

尝试搜索解决方案此处此处,但是解决方案更特定于上下文,而不是更通用的解决方案。有人可以建议我该怎么做吗?

Have tried to search the solution here, here and here but the solutions are more context specific rather than something more generic. Could any one suggest what I can do?

推荐答案

我认为我已经回答了我的问题。
我可以将命令的参数捆绑在 .rsp 文件中,并在可执行文件的路径前加上 @,然后将其与可执行文件一起在命令提示符下启动。
因此,对于此命令:

I think I got the answer to my question. I can bundle the arguments of the command in an .rsp file and fire it up on my command prompt with the executable after prepending its path by '@'. So, for this command:

cl.exe foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

我放了这个

foo.dll (around 1500 .obj files) (couple of other statically linked libraries)

在文件中说 makeDLL.txt 。通过更改其扩展名( makeDLL.rsp )将其更改为 .rsp 文件并启动以下命令:

inside a file say makeDLL.txt. Change it to a .rsp file by changing its extension (makeDLL.rsp) and fire up this command:

cl.exe @<full-path of makeDLL.rsp>

这对我有用。

这篇关于在Windows命令提示符下链接.obj文件时,“命令行太长”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆