这是indexloc提供的服务,不要输入任何密码
Skip to content

Clang can't link readline program on Android 5 #4287

@ghost

Description

Problem description
Clang produces strange linking errors when trying to link readline program.

$ clang test.c -lreadline
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `strtol@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `fwrite@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `longjmp@LIBC'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: /data/data/com.termux/files/usr/lib/libreadline.so: undefined reference to `__errno@LIBC'
<some lines skipped>
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce

  1. Make sure your device running Android OS v5.x (just android-5 packages isn't enough).

  2. Put following content to test.c:

#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>

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;
}
  1. clang test.c -lreadline

Expected behavior
Program should be compiled successfully.

Additional information

Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/grimler/science-packages-21 science/stable
https://dl.bintray.com/grimler/game-packages-21 games/stable
https://termux.net stable/main
https://termux.net stable/main
System information:
Linux localhost 3.1.10-gf5d7b8b #1 SMP PREEMPT Thu Jan 8 04:50:16 UTC 2015 armv7l Android
Termux-packages arch:
arm
Android version:
5.1.1
Device manufacturer:
asus
Device model:
Nexus 7

Initially issue was reported on mailing list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    android-5.xIssue happens on devices running Android 5.xbug reportSomething is not working properly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions