【问题标题】:ld cannot recognize the optionsld 无法识别选项
【发布时间】:2016-08-12 21:42:32
【问题描述】:

我正在阅读此Tuto,我正在尝试使用此命令链接应用程序:ld test.o –o test.bin,链接器无法识别-o 选项:

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

使用ld -help 选项-o 存在,但我不明白为什么会遇到这个问题。

这是链接器版本。

$ 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.

【问题讨论】:

    标签: linux gcc linker ld


    【解决方案1】:

    我的好眼睛和痛苦的经历告诉我,您一定复制/粘贴了一些来自 MS-Office 的文本,其中破折号 (-) 已转换为另一个 unicode 或其他破折号。注意文本中短划线字符的长度。

    实际上,您所指的 tuto 是错误的,例如在这一行中:

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

    请注意不能在命令行上运行的 2 个臭名昭著的“长破折号”。

    您的命令原样,然后是重新键入的命令。注意到什么了吗?

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

    由于破折号不正确,ld 假定这是一个目标文件并尝试打开它,因此出现错误。

    【讨论】:

    • 很好,它解决了我的问题,非常感谢
    猜你喜欢
    • 2015-10-09
    • 2021-04-04
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    相关资源
    最近更新 更多