LD Linker: -T is not recognized?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

LD Linker: -T is not recognized?

Post 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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: LD Linker: -T is not recognized?

Post by gerryg400 »

Are you sure you are using the cross-compiled ld that you created ? It's not normally callled 'ld'.
If a trainstation is where trains stop, what is a workstation ?
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

Re: LD Linker: -T is not recognized?

Post 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$ 
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: LD Linker: -T is not recognized?

Post 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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: LD Linker: -T is not recognized?

Post 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
If a trainstation is where trains stop, what is a workstation ?
Aaron
Posts: 7
Joined: Sun May 15, 2011 2:43 pm

Re: LD Linker: -T is not recognized?

Post 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?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: LD Linker: -T is not recognized?

Post 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.
Every good solution is obvious once you've found it.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: LD Linker: -T is not recognized?

Post 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.
If a trainstation is where trains stop, what is a workstation ?
User avatar
casnix
Member
Member
Posts: 67
Joined: Fri Jan 14, 2011 7:24 pm

Re: LD Linker: -T is not recognized?

Post 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).
You are a computer.
~ MCS ~
Post Reply