C(++) 编译器转换 - 请让 DJGPP 消失
我正在编写一个内核,并且有几个朋友和我一起参与这个项目。 我们使用 DJGPP 编译该项目已经有一段时间了,但是我们在以这种方式编译时遇到了一些跨平台兼容性问题,导致项目上的主要 Partnet 无法在 Windows XP 上进行编译。 (DJGPP 的 GCC 在 Windows XP 上遇到超过 127 个参数列表的问题,但在 Vista 上没有相同参数列表的问题。所以,这一次,Vista 在某些方面比 XP 工作得更好。oO)
任何人,而不是尝试工作为了让这该死的东西能够用 DJGPP 进行编译,我们做了一些肮脏的修改,我们决定完全放弃 DJGPP,并使用 Windows 的不同版本的 GCC。 问题是,MinGW(据我所知)不允许我们对代码的汇编部分使用 NASM 语法,此时将其全部转换为 AT&T 语法会有点痛苦。 当然有可能,因为它还处于项目的早期阶段,但是很痛苦。
所以现在你知道这个问题了。 我的问题是:哪种 Windows 的 GCC 编译器发行版可以让我们最轻松地将这个项目移植到自身? 理想情况下,我们正在寻找可以执行 NASM 汇编器语法、不依赖外部 dll(这里是内核,它无法访问它们)并且能够在 Windows 上的多个版本上一致工作的东西。 您对执行此操作的最佳方法有何建议?您推荐 Windows 版 GCC 的哪个版本?
请注意,如果我们需要将项目转换为 AT&T 语法,那也可以,但我不想这样做。 我们实际上使用 NASM 来组装它的汇编位,并生成一个有效的 .o 文件,但 MinGW 由于某种原因无法链接它。 我认为内联汇编位(可能 5 行)已经是 AT&T 语法,按照 GCC 的要求。
谢谢!
I'm working on writing a kernel, and I have a few friends working with me on the project. We've been using DJGPP to compile the project for a while, but we're having some cross-platform compatibility issues with compiling this way that have left my main Partnet on the project unable to compile on Windows XP. (DJGPP's GCC is having issues with argument lists longer than 127 on windows XP, but not having issues with the same argument lists on Vista. So, for once, Vista works better than XP at something. o.O)
Anywho, rather than try to work out some dirty hack to make the darn thing compile with DJGPP, we've decided that we want to ditch DJGPP entirely and work with a different version of GCC for windows. The trouble is, MinGW (to my knowledge) doesn't let us use NASM syntax for the assembly portions of the code, and it would be a bit of a pain to convert it all to AT&T syntax at this point. Possible of course, since its fairly early in the project, but a pain.
So now you know the issue. My question is this: What GCC compiler distro for Windows will allow us to most easily port this project to itself? Ideally, we're looking for something that can do NASM assembler syntax, not have any reliance on externel dlls (this is a kernel here, it won't have access to them) and will work consistantly on multiple versions on Windows. What are your recommendations about the best way to go about doing this, and what version of GCC for windows do you recommend?
Note that if we are going to need to convert the project to AT&T syntax that's OK, I'd just like to not do that. We're actually using NASM to assemble the assembly bits of it, and that produces a valid .o file, but MinGW isn't able to link that in for some reason. I think the inline assembly bits (maybe 5 lines) are already AT&T syntax, as required by GCC.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能使用 -f 选项将错误的对象类型传递给 nasm。
我敢打赌你会通过 -f coff 。
您需要传递 -f win32。
You are probably passing the wrong object type to nasm with the -f option.
I'll bet you're passing -f coff.
You will need to pass -f win32.
构建交叉编译器。
http://wiki.osdev.org/GCC_Cross-Compiler
这是我从用于在 Windows 主机上进行开发的 DJGPP。 我推荐Cygwin方法,因为它比MSYS稍微稳定一些。
完成此操作后,配置 NASM 来构建
elf32
对象文件,然后就可以开始了。Build a cross-compiler.
http://wiki.osdev.org/GCC_Cross-Compiler
This is what I did when transitioning from DJGPP for development on a Windows host. I recommend the Cygwin method, as it's slightly more stable than MSYS.
Once you've done that, configure NASM to build
elf32
object files, and you're good to go.您使用的是为 DOS 还是 Windows 编译的 NASM? 我没看,但可能有区别。 另外,如果您的 NASM 太旧,它可能无法生成 MinGW 可以理解的东西。
快速 Google 搜索发现了在 MinGW 下编译 x264 的教程,其中步骤之一是在 MinGW 上编译 NASM。
如果失败,您可以尝试使用 objcopy(如对另一个答案的评论所建议的那样)。
Are you using NASM compiled for DOS or for Windows? I did not look, but it is possible that there is a difference. Also, if your NASM is too old, it might not be able to generate something MinGW can understand.
A quick Google search found a tutorial on compiling x264 under MinGW, where one of the steps is to compile NASM on MinGW.
Failing that, you could try (as suggested on a comment to another answer) using objcopy.