File format not recognized
File format not recognized
Hi All,
I'm following this tutorial http://www.osdever.net/bkerndev/Docs/title.htm, but I'm not able to link.
At the end ld says, "File format not recognized" and it is referring to the assembler file included in that tutorial.
As tools I'm using MinGW (mingw.org) and nasm, both recently downloaded.
I'm not using DJGPP because I have a 64 bit Windows, 7.
Any suggestion?
Thank you.
I'm following this tutorial http://www.osdever.net/bkerndev/Docs/title.htm, but I'm not able to link.
At the end ld says, "File format not recognized" and it is referring to the assembler file included in that tutorial.
As tools I'm using MinGW (mingw.org) and nasm, both recently downloaded.
I'm not using DJGPP because I have a 64 bit Windows, 7.
Any suggestion?
Thank you.
Last edited by CodeVisio on Sat Aug 25, 2012 2:19 am, edited 1 time in total.
Re: File format not recognized
By default nasm produces bin format files. You are specifying "-f elf" on the command line, I presume?
Re: File format not recognized
No, I'm following exactly what the tutorial says, that is:By default nasm produces bin format files. You are specifying "-f elf" on the command line, I presume?
From build.bat file:
nasm -f aout -o start.o start.asm.
Thank you.
Re: File format not recognized
A modern version of ld will almost certainly be expecting elf format input files by default. If you want to use an alternative format then you have to tell it so. The easiest solution is just to use elf format all round.
You need to understand your toolset; don't follow tutorials blindly. But these mistakes are good as they help us better understand what we are doing.
You need to understand your toolset; don't follow tutorials blindly. But these mistakes are good as they help us better understand what we are doing.
Re: File format not recognized
Before posting here I've tried different nasm object file format output and ld claims with different errors.A modern version of ld will almost certainly be expecting elf format input files by default. If you want to use an alternative format then you have to tell it so. The easiest solution is just to use elf format all round.
I've tried nasm with aout, bin, elf, elf32, elf64, coff, win32, win64 ecc but without success.
My first guess was that ld, and so MinGW, was targeted, as release, for 32 bit Windows, but I'm not quite sure.
I agree.You need to understand your toolset; don't follow tutorials blindly. But these mistakes are good as they help us better understand what we are doing.
Any suggestion?
Thank you.
Re: File format not recognized
Build a cross-compiler as you are not compiling Windows programs: http://www.mingw.org/wiki/HostedCrossCompilerHOWTO .
Alternatively, install Linux in a VM and use that for OS development. In the end I found Windows too much of a pain as a development environment.
Alternatively, install Linux in a VM and use that for OS development. In the end I found Windows too much of a pain as a development environment.
Re: File format not recognized
I've read the info on that page... I dont' know if I have the strength to do so.Build a cross-compiler as you are not compiling Windows programs: http://www.mingw.org/wiki/HostedCrossCompilerHOWTO .
Indeed I was able to compile and link all those files from the tutorial on a linux pc, but since I have all my dev stuff here, on the Windows pc, I didn't want to switch PCs.Alternatively, install Linux in a VM and use that for OS development. In the end I found Windows too much of a pain as a development environment.
I'll try it and provide feedback here.
Thank you
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: File format not recognized
How long do you plan on getting stuck with this?I dont' know if I have the strength to do so.
Re: File format not recognized
Building a cross-compiler is pretty much essential for OS development and is one of the easier tasks (especially with step-by-step instructions). It doesn't bode well for any further ambitions you may have.I dont' know if I have the strength to do so.
Re: File format not recognized
I've just gave a look at the mingw web page mentioned above about cross platform and:
The tools the web page talks about are not updated, as mentioned at top of the page itself.
I give up since I don't know how much time it would take and I don't like spending time and just discovering at the end
that the tools are not the right ones or are not long compatible etc etc.
So I'll continue on linux pc.
One more thing:
When I installed MinGW distribution I believed the tools coming with MingW were much the same as the counterpart you find on linux.
Let's take gcc for example: gcc is ported o Windows platform so I can run it from the cmd.exe command line, at the same time I believed that
the entire porting was related only on the platform it needs to run on and not related to its features. In other word I believed I can run gcc with same parameters and get the same result on linux as on Windows. Am I wrong?
Thank you.
The tools the web page talks about are not updated, as mentioned at top of the page itself.
I give up since I don't know how much time it would take and I don't like spending time and just discovering at the end
that the tools are not the right ones or are not long compatible etc etc.
So I'll continue on linux pc.
One more thing:
When I installed MinGW distribution I believed the tools coming with MingW were much the same as the counterpart you find on linux.
Let's take gcc for example: gcc is ported o Windows platform so I can run it from the cmd.exe command line, at the same time I believed that
the entire porting was related only on the platform it needs to run on and not related to its features. In other word I believed I can run gcc with same parameters and get the same result on linux as on Windows. Am I wrong?
Thank you.
Re: File format not recognized
If it works on Linux but not on Windows then obviously the toolsets are not the same. I don't really know anything about mingw but I guess it's configured to create Windows excecutables.
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: File format not recognized
MinGW is a port of basic GNU utilities, mainly the GNU Compiler Collection (GCC) and binutils (as, ld, objcopy, objdump, nm, ar, ...) to Windows, as an alternative to Microsoft's development tools. It is only meant to be used to create Windows PE executables, but uses ELF as an intermediate format when creating object files. If you wish to do OS development, either make a flat binary kernel, use a PE format kernel (which is harder to read than ELF), or build a cross-compiler. If you can't do one of those, then you are not ready for OS development.
Re: File format not recognized
Hi Tosi!
Question: do you think it's possible to develop an OS with VC compiler + tasm (or nasm)? (otherwise how could Microsft ever developed its own...)
However, I'm interested in this:
What is the logical and practical implication between "build a cross compiler" and "you are not ready for OS development"?
Thank you for your information
This is the point where I came at the end of my inspection.MinGW is a port of basic GNU utilities, mainly the GNU Compiler Collection (GCC) and binutils (as, ld, objcopy, objdump, nm, ar, ...) to Windows, as an alternative to Microsoft's development tools. It is only meant to be used to create Windows PE executables, but uses ELF as an intermediate format when creating object files.
Question: do you think it's possible to develop an OS with VC compiler + tasm (or nasm)? (otherwise how could Microsft ever developed its own...)
I've tried with -f win32 and -f win64 option from nasm but it didn't work.If you wish to do OS development, either make a flat binary kernel, use a PE format kernel (which is harder to read than ELF), or build a cross-compiler.
I don't think it is feasible for someone only to make a complete OS, from technical, time, and commercial point of views.If you can't do one of those, then you are not ready for OS development.
However, I'm interested in this:
What is the logical and practical implication between "build a cross compiler" and "you are not ready for OS development"?
Thank you for your information
Re: File format not recognized
As it's a suggestion that I also made, I'll add my take on this.What is the logical and practical implication between "build a cross compiler" and "you are not ready for OS development"?
Look upon it as a sort of test (as well as providing a useful utility). Building a cross-compiler is orders of magnitude simpler than writing an OS. If you find the former too difficult then you will only find the latter frustrating.
Re: File format not recognized
I think I got it and I agree totally.