Page 1 of 1
LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 6:49 pm
by Aaron
Yup. Pretty straight forward. In Terminal, when I use ld -T link.d -o blahblahblahwheteverfilesihave it says "ld: uknown option: -T" And yes, I have the GCC Cross-Compiler.
Re: LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 7:14 pm
by gerryg400
Are you sure you are using the cross-compiled ld that you created ? It's not normally callled 'ld'.
Re: LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 7:26 pm
by Aaron
Alright... I used AR this time. Still didn't work.
Terminal:
Code: Select all
Aarons-MacBook:trolololo Aaron$ ar -rcs archive.a loader.s kernel.o
Aarons-MacBook:trolololo Aaron$ cc kernel.c archive.a -o kernel.bin
ld: warning: in archive.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Aarons-MacBook:trolololo Aaron$
Re: LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 7:33 pm
by quok
If you're on OS X, and you built an i686 cross compiler, you'll need to prepend "i686-elf-" to all the tool names.
So, ld becomes i686-elf-ld, ar becomes i686-elf-ar, etc. You're trying to use the host tools currently, not the cross compiler tools.
Re: LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 7:36 pm
by gerryg400
You need a cross-compiled version of binutils as well. That will give you an ld called something like "i386-elf-ld".
The mac version of ld simply can never work. It is not actually the 'binutils ld' and does not support the -T option.
[edit]Quok is quik
Re: LD Linker: -T is not recognized?
Posted: Sun May 15, 2011 11:29 pm
by Aaron
Alright, I've tried a billion times to get GCC cross-compiler to work. But it doesn't. So, is it easier to develop on Windows?
Re: LD Linker: -T is not recognized?
Posted: Mon May 16, 2011 12:05 am
by Solar
You don't have to try a billion times, you just have to do it
right. Once. That tutorial is the most well-tested of all our Wiki content. It is
correct.
You did not acknowledge the suggestions given to you so far, which are prose for pointing you to this part to the tutorial which you most likely missed:
Usage
Once you are finished, your toolset resides in /usr/local/cross. For example, you have a gcc executable in /usr/local/cross/bin/$TARGET-gcc (and /usr/local/cross/$TARGET/gcc as well), which spits out binaries for your TARGET. Add /usr/local/cross/bin to your PATH environment variable, so that gcc invokes your system compiler, and $TARGET-gcc invokes your cross-compiler.
Previous posters were pointing out that you not only need to call $TARGET-gcc, but also $TARGET-ld and $TARGET-ar.
I will update the tutorial to make this explicit.
Re: LD Linker: -T is not recognized?
Posted: Mon May 16, 2011 12:28 am
by gerryg400
Alright, I've tried a billion times to get GCC cross-compiler to work. But it doesn't. So, is it easier to develop on Windows?
Many of us develop on Mac and use a cross-compiled binutils/gcc. It definitely works. I tried OS development on Windows, Linux and Mac and choose Mac.
I just then followed the tutorial and found I had to add --disable-werror to the configure command line for binutils. Apart from that there seems to be no problem.
Please post your issues and they can be fixed.
Re: LD Linker: -T is not recognized?
Posted: Mon May 23, 2011 5:09 pm
by casnix
I'm just gonna say that depending on the gcc version you're trying to build, you may need other dependencies (its all in the wiki). Also, unless you're using mac ports or Xcode for your host compiler (if you have a prepackaged gcc on your mac) you NEED to upgrade (also in the wiki).