Undefined reference to a function in another library

前端 未结 4 1392
自闭症患者
自闭症患者 2021-01-25 04:24

I\'m trying to compile an object code with a reference to one lib. This is the code of libexample.c:

#include \"libexample.h\"
#include 
#include         


        
4条回答
  •  伪装坚强ぢ
    2021-01-25 04:50

    Add -lrt to your link command. timer_create and timer_settime are not part of the C Standard library.

    gcc -fPIC -shared libexample.c -lrt -o libexample.so
    gcc -L. example.c -lexample -o example
    

提交回复
热议问题