3

I was writing a simple shell program in Termux in Android 5 (Lollipop) with GNU readline library in C program. I am getting linker error on compiling the below code. The same code is works fine in Android 9' Termux. I have verified the readline Dev package also.

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;
}

Compiled as: $ cc -lreadline rl.c

Here is the linker error

/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)
Kirubakaran
  • 378
  • 4
  • 20

0 Answers0