【问题标题】:Getting undefined reference to 'clock_gettime' error, for curl program对于 curl 程序,获取对“clock_gettime”错误的未定义引用
【发布时间】:2012-03-02 10:36:37
【问题描述】:

问候,

我有交叉编译、OpenSSl、libssh2,最后是 cURL,不知道为什么它只生成静态库。无论如何,我尝试通过链接所有三个库来运行示例 ftpget.c 程序,但出现以下错误:

.../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

请帮我解决这个错误,是否还需要交叉编译任何其他库?

谢谢, 尤维

【问题讨论】:

    标签: c curl libcurl cross-compiling


    【解决方案1】:

    尝试使用 librt (-lrt) 链接。

    【讨论】:

    • @Yuvi:交叉编译?我假设您在 Linux 上运行; librt 应该始终可用(我希望!)。
    【解决方案2】:

    您需要链接实时库。
    使用-lrt

    gcc ... -lrt ...
    

    【讨论】:

    • 我正在交叉编译arm,
    最近更新 更多