Page 1 of 3

ld linker error

Posted: Tue Jun 23, 2009 10:32 pm
by Gman
Ok, I'm sure if this is the right place to post this but i am following Bran's tutorial and when i was compiling the source files I would get and error in ld. So, I downloaded the final project at the end and tried compiling that and it gave me the same error, this:

Code: Select all

start.o: file not recognized: File format not recognized
start.o is a asm file compiled with nasm, and the rest of the files are c code.
my version of nasm is: 2.05
my version of ld is:2.15.91

again i took the code from the website and downloaded the files, and made NO edits to them

thanks

Re: ld linker error

Posted: Tue Jun 23, 2009 10:37 pm
by JackScott
I suspect I know the answer to this question, but to confirm I need to ask another question: What compiler are you using? Is it Cygwin, MingW, or basically anything other than standard GCC on a standard i386 Linux system? If so, you'll need to create a GCC_Cross-Compiler.

Re: ld linker error

Posted: Tue Jun 23, 2009 10:57 pm
by Gman
I'm using gcc on a windows system, I could never get bochs to work correctly on linux

Re: ld linker error

Posted: Tue Jun 23, 2009 11:13 pm
by JackScott
Yep, you'll be needing to make a GCC Cross Compiler. When you choose the version of GCC to build, if you choose GCC v4.2.x or less, it'll be easier to build. But GCC v4.3.x or more has some cool extra features (not that I've ever used them).

Re: ld linker error

Posted: Tue Jun 23, 2009 11:16 pm
by Gman
Are you sure the problems with gcc, the files compiled fine. I think, and I could be easily wrong, that the problem is in nasm.

Re: ld linker error

Posted: Tue Jun 23, 2009 11:37 pm
by JackScott
Rebuilding GCC also rebuilds LD. Basically the set of tools that Cygwin provides are tricky to get to work with OSDev properly (it can be done, but it's a mess and I've forgotten how). You're best of creating a whole new set specially for OSDev.

You might also want to try the Barebones, to see if that will compile and run.

Btw, welcome to the forums. We need more Pink Floyd fans here. :)

Re: ld linker error

Posted: Tue Jun 23, 2009 11:45 pm
by pcmattman
As Jack Scott has already mentioned, you'll need a cross-compiler for Windows development with bkerndev.

However, you should also change the NASM command line a little. It has an "-f aout" where it should be "-f elf".

Re: ld linker error

Posted: Tue Jun 23, 2009 11:52 pm
by Gman
Ok, I think I am going to try to compile everything under linux, I hope it works

Re: ld linker error

Posted: Wed Jun 24, 2009 2:11 am
by Solar
Is it just me, or is it happening far too often that several people tell someone that the solution is A) and he proceeds to do B)?

Strange...

Re: ld linker error

Posted: Wed Jun 24, 2009 7:17 am
by yemista
what problems were you having getting bochs to work under linux? I had some as well and might be able to help. I could never get cygwin running correctly though...

Re: ld linker error

Posted: Wed Jun 24, 2009 7:32 pm
by Gman
Ok so I am trying to make a cross-compiler, like you told me. I am following the tut on the Wiki. I am using cygwin. But, when I use the make all command it works for a while, but then it fails at checking size of integer.
the error is

Code: Select all

configure: error: cannot compute sizeof <int>, 77
My binutils version I am trying to compile with is 2.19.1
My gcc version I am trying to compile with is 4.4.0
I attached the .log file, but had to rename it .txt

Re: ld linker error

Posted: Wed Jun 24, 2009 8:42 pm
by pcmattman
Your posted config.log is from the build root. What you need is the config.log from the subdirectory of your build directory for the failed configure script.

For instance, it might fail while building the "libiberty" target - you'd then look for "<build directory>/libiberty/config.log".

Re: ld linker error

Posted: Wed Jun 24, 2009 11:03 pm
by pChan
Off-topic but when I saw this
I'm using gcc on a windows system, I could never get bochs to work correctly on linux
I was reminded of the problem I faced in installing bochs in my ubuntu machine. I remember it had something to do with hash_map. I got the fix in a gentoo forum. Felt so much better when I got it to work.

Re: ld linker error

Posted: Wed Jun 24, 2009 11:09 pm
by Gman
Ok, here is the right file, I will try again on the bochs thing, I had to erase my Ubuntu installation, and so i just installed the newest version.

Re: ld linker error

Posted: Wed Jun 24, 2009 11:59 pm
by pcmattman
Right,
configure:4690: gcc -o conftest.exe -g -O2 conftest.c >&5
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot open output file conftest.exe: Permission denied
Uh oh! Looks like it can't write to (or create) that file. Are you on Vista or Windows 7, by chance?