views:

516

answers:

2

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!

+1  A: 

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.

Joshua
When passing -f Win32 (as with before) I still get the following error from MinGW's GCC: "assembly/start.o: file not recognized: File format not recognized"
Nicholas Flynt
or, more generally: use file(1) to check what kind of file nasm produces, and what kind of file gcc produces, and then change options until they match. If you can't specify the right options, use objcopy
Martin v. Löwis
weird. I have a MinGW/NASM project and -f win32 is how I build the nasm component myself.
Joshua
I discovered the real problem. It wasn't the .o files, it was in fact my linker script. I'm searching for an answer on that.
Nicholas Flynt
Found it. Changing the output type the linker script was using to something that agreed with everyone was the key. This answer definitely pointed in the correct direction. Thanks a bunch!
Nicholas Flynt
A: 

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.

CesarB