making gcc prefer static libs to shared objects when linking?

后端 未结 3 1018
逝去的感伤
逝去的感伤 2020-12-30 23:52

When linking against libraries using the -l option (say -lfoo), gcc will prefer a shared object to a static library if both are found (will prefer

相关标签:
3条回答
  • 2020-12-31 00:19

    Just add the .a file to the link line without -l as if it were a .o file.

    0 讨论(0)
  • 2020-12-31 00:19

    It's dated, but may work: http://www.network-theory.co.uk/docs/gccintro/gccintro_25.html

    (almost end of the page)

    "As noted earlier, it is also possible to link directly with individual library files by specifying the full path to the library on the command line."

    0 讨论(0)
  • 2020-12-31 00:24

    You can specify the full path to the static libs without the -l flag to link with those.

    gcc ... source.c ... /usr/lib32/libmysuperlib.a ...
    
    0 讨论(0)
提交回复
热议问题