Skip to content
Advertisement

ld cannot recognize the options

I’am reading this Tuto, and I’am trying to link the application using this command: ld test.o –o test.bin, the linker doesn’t recognize the -o option :

ld: cannot find –o: No such file or directory

Using ld -help the option -o exist but i don’t understand why I’am getting this problem.

This is the linker version.

$ ld -version
GNU ld (GNU Binutils for Ubuntu) 2.24
Copyright 2013 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later  version.
This program has absolutely no warranty.

Advertisement

Answer

My good eyes and my bitter experience tell me that you must have copied/pasted some text coming from MS-Office where the dash (-) has been converted to another dash which is unicode or whatever. Notice the length of the dash character in your text.

Actually, the tuto you were refering to is the one at fault, ex in this line:

ld –Ttext 0x7c00 --oformat=binary test.o –o test.bin

Note the 2 infamous “long-dashes” that cannot work on a command line.

Your command as-is, followed by the retyped command. notice something?

ld test.o –o test.bin   # long dash, fails
ld test.o -o test.bin   # good one, short dash

Since the dash is not the correct one, ld assumes that this is an object file and tries to open it, hence the error.

Advertisement