1.动态库和静态库都存在的时候,默认选择动态库。 2.使用-static选项可以链接静态库,但要求所有库都有静态库,如果没有,会报错。 3.使用-Wl,-Bstatic和-Wl,-Bdynamic选项分别来知道链接静态库和动态库,这样比较灵活;或者指定静态库路径。 ``` -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.

-Bdynamic
-dy
-call_shared
       Link against dynamic libraries.  This is only meaningful on platforms for
       which shared libraries are supported.  This option is normally the default
       on such platforms.  The different variants of this option are for
       compatibility with various systems.  You may use this option multiple times
       on the command line: it affects library searching for -l options which
       follow it.


 -Bstatic
 -dn
 -non_shared
 -static
     Do not link against shared libraries.  This is only meaningful on platforms
     for which shared libraries are supported.  The different variants of this
     option are for compatibility with various systems.  You may use this option
     multiple times on the command line: it affects library searching for -l
     options which follow it.  This option also implies
     --unresolved-symbols=report-all.  This option can be used with -shared.
     Doing so means that a shared library is being created but that all of the
     library's external references must be resolved by pulling in entries from
     static libraries.

```

0 回复
需要 登录 后方可回复, 如果你还没有账号你可以 注册 一个帐号。