clang-8:错误:链接器命令失败,退出代码为1

时间:2019-09-08 03:35:00

标签: android c ld termux libreadline

我正在用Android 5(Lollipop)中的Termux用C程序中的GNU readline库编写一个简单的shell程序。 我在编译以下代码时遇到链接器错误。在Android 9'Termux中,相同的代码也可以正常工作。我还验证了readline开发包。

int main(int argc, char** argv) 
{
    char* buf;
    while ((buf = readline("$ ")) != NULL) {
        if (strlen(buf) > 0) {
            add_history(buf);
        }

        printf("echo [%s]\n", buf);
        free(buf);
    }

    return 0;
}

编译为: $ cc -lreadline rl.c

这是链接器错误

/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `malloc@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `fprintf@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `read@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `getenv@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `rename@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `sigdelset@LIBC'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

0 个答案:

没有答案