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

后端 未结 2 417
没有蜡笔的小新
没有蜡笔的小新 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
    

提交回复
热议问题