轮候册,期权和QUOT ...之间QUOT任何差异;和" -Xlinker选项"语法GCC [英] Any difference between "-Wl,option" and "-Xlinker option" syntax for gcc

查看:112
本文介绍了轮候册,期权和QUOT ...之间QUOT任何差异;和" -Xlinker选项"语法GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过一些配置文件和我见过两个正在使用(虽然在不同的架构)。如果您使用在Linux中的gcc是有传球选择给连接器两个参数之间有什么区别?阅读GCC手册它们据我可以告诉解释几乎相同。


解决方案

我真的不知道该做些什么比仰望男人的gcc ,你应该保持考虑到为未来的问题有关GCC调用。所以:


  

-Xlinker选项


  
  

    

把option作为一个选项给连接器。您可以使用此提供哪些GCC不知道如何识别的特定系统链接器选项。


    
    

如果你想通过这需要一个单独的参数的选项,则必须使用-Xlinker两次,一次是为选项,另一次的说法。例如,通过-assert定义,你必须写-Xlinker -assert -Xlinker定义。它不工作,写-Xlinker-assert定义,因为这传递整个字符串作为一个参数,这是不是连接器所期待的。


    
    

在使用GNU链接,它通常更方便使用传递比作为独立参数选项= value语法参数链接选项是。例如,您可以指定-Xlinker -Map = output.map而不是-Xlinker -Map -Xlinker output.map。其它接头可能不支持此语法的命令行选项。


  
  
  

轮候册,选


  
  

    

把option作为一个选项给连接器。如果option中包含逗号,把它拆成逗号多个选项。你可以使用这个语法来传递参数的选项。


    
    

例如,轮候册,-Map,output.map传递-Map output.map给链接器。当使用GNU链接,你也可以得到轮候册相同的效果,-Map = output.map。


  

你可以SE,唯一的区别是, -Wl 允许一个逗号意味着你可以指定多个参数,如轮候册, -rpath,/我/库,你不能用 -Xlinker 做到;在另一方面, -Xlinker 也许是多一点自我描述。任你选。还要检查其他的编译器( NVCC 想到,和),看是否有他们的语法一致,然后使用该便携性,如果这对你很重要。

I have been looking through some configuration files and I've seen both being used (albeit on different architectures). If you're using gcc on a linux box is there any difference between the two syntax for passing options to the linker? Reading the gcc manual they are explained almost identical as far as I could tell.

解决方案

I don't really know what else to do than look up man gcc, which you should keep in mind for future questions pertaining to gcc invocation. So:

-Xlinker option

Pass option as an option to the linker. You can use this to supply system-specific linker options which GCC does not know how to recognize.

If you want to pass an option that takes a separate argument, you must use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It does not work to write -Xlinker "-assert definitions", because this passes the entire string as a single argument, which is not what the linker expects.

When using the GNU linker, it is usually more convenient to pass arguments to linker options using the option=value syntax than as separate arguments. For example, you can specify -Xlinker -Map=output.map rather than -Xlinker -Map -Xlinker output.map. Other linkers may not support this syntax for command-line options.

-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option.

For example, -Wl,-Map,output.map passes -Map output.map to the linker. When using the GNU linker, you can also get the same effect with -Wl,-Map=output.map.

As you can se, the only difference is that -Wl allows you to specify multiple arguments by means of a comma, like -Wl,-rpath,/my/libs, which you cannot do with -Xlinker; on the other hand, -Xlinker is maybe a bit more self-descriptive. Take your pick. Also check other compilers (nvcc comes to mind, and clang) to see if any of them agree on the syntax, and then use that for portability if that's important to you.

这篇关于轮候册,期权和QUOT ...之间QUOT任何差异;和" -Xlinker选项"语法GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆