ld linker error

Programming, for all ages and all languages.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

ld linker error

Post 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
"For those about to rock, we salute you"
-Brian Johnson
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: ld linker error

Post 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.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

I'm using gcc on a windows system, I could never get bochs to work correctly on linux
"For those about to rock, we salute you"
-Brian Johnson
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: ld linker error

Post 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).
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post 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.
"For those about to rock, we salute you"
-Brian Johnson
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: ld linker error

Post 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. :)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post 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".
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

Ok, I think I am going to try to compile everything under linux, I hope it works
"For those about to rock, we salute you"
-Brian Johnson
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: ld linker error

Post 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...
Every good solution is obvious once you've found it.
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: ld linker error

Post 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...
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post 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
Attachments
config.txt
(22.91 KiB) Downloaded 98 times
"For those about to rock, we salute you"
-Brian Johnson
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post 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".
pChan
Posts: 4
Joined: Thu Feb 05, 2009 12:08 am

Re: ld linker error

Post 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.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post 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.
Attachments
config.txt
(29.1 KiB) Downloaded 107 times
"For those about to rock, we salute you"
-Brian Johnson
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post 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?
Post Reply