how to force linker to use shared library instead of static library?

后端 未结 2 418
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 02:54

This is a quote from Linux programming book:


% gcc -o app app.o -L. –ltest

Suppose that both libtest.

相关标签:
2条回答
  • 2020-12-31 03:30

    You could use -l option in its form -l:filename if your linker supports it (older versions of ld didn't)

    gcc -o app app.o -L. -l:libtest.so
    

    Other option is to use the filename directly without -l and -L

    gcc -o app app.o /path/to/library/libtest.so
    
    0 讨论(0)
  • 2020-12-31 03:34

    from the man :

    -shared-libgcc
    -static-libgcc
    On systems that provide libgcc as a shared library, these options force the use of either the shared or static version respectively. If no shared version of libgcc was built when the compiler was configured, these options have no effect.

    good luck

    0 讨论(0)
提交回复
热议问题