Getting undefined reference to 'clock_gettime&

2020-02-06 10:44发布

Gretings,

I have cross compile, OpenSSl , libssh2 and finally cURL, Don't know why it has generated only static library. Anyway I tried to run sample ftpget.c program by linking all the three libraries but I am getting the following error :

.../libcurl.a(timeval.o): In function 'curlx_tvnow':
timeval.c:(.text+0xfc): undefined reference to 'clock_gettime'
collect2: ld return  1 exit status
make: *** [all] Error 1

Please help me resolve this error, Is there need to cross-compile any other library also ?

Thanks, Yuvi

2条回答
【Aperson】
2楼-- · 2020-02-06 11:01

Try linking with librt (-lrt).

查看更多
Juvenile、少年°
3楼-- · 2020-02-06 11:04

You need to link with the real-time library.
Use -lrt

gcc ... -lrt ...
查看更多
登录 后发表回答