Shared libraries and .h files

后端 未结 4 1972
自闭症患者
自闭症患者 2020-12-12 19:52

I have some doubt about how do programs use shared library.

When I build a shared library ( with -shared -fPIC switches) I make some functions available from an exte

4条回答
  •  悲&欢浪女
    2020-12-12 20:25

    You need to give the linker the proper instructions to link your shared library.

    The shared library names are like libNAME.so, so for linking you should use -lNAME

    Call it libmysharedlib.so and then link your main program as:

    gcc -o myprogram myprogram.c -lmysharedlib 
    

提交回复
热议问题