Linux:using the the readline library [error] undefined reference to `readline'

简介: Linux:using the the readline library [error] undefined reference to `readline'

To install the readline library, open the terminal window and write

sudo apt-get install libreadline-dev

It will ask for your password. Enter it. Press y in the next step.

CODE:

1. #include <stdio.h>
2. #include <malloc.h>
3. #include <readline/readline.h>
4. 
5. void main(void){
6. 
7. char *line;
8. 
9. while( 1==1 ){
10.     line=readline("enter text>");
11.     printf("text: %s <\n",line);
12.     free(line);
13.     }
14. }

ERROR:

1. /tmp/cc6JYBvf.o: In function `main':
2. read_test.c:(.text+0xe): undefined reference to `readline'

SOLVE:

You need to link againts the actual library using -lreadline in gcc arguments:

gcc read_test.c -o read_test -lreadline

 

AIEarth是一个由众多领域内专家博主共同打造的学术平台,旨在建设一个拥抱智慧未来的学术殿堂!【平台地址:https://devpress.csdn.net/aiearth】 很高兴认识你!加入我们共同进步!

目录
相关文章
|
Kubernetes Java Linux
Linux|操作系统|Error: Could not create the Java Virtual Machine 报错的解决思路
Linux|操作系统|Error: Could not create the Java Virtual Machine 报错的解决思路
3062 0
|
小程序 前端开发 API
【微信小程序】TypeError: Cannot read property ‘get‘ of undefined & Error: MiniProgramError
【微信小程序】TypeError: Cannot read property ‘get‘ of undefined & Error: MiniProgramError
|
资源调度 前端开发
编译第三方前端项目时候出现Syntax Error: TypeError: Cannot set properties of undefined (setting ‘parent‘)
编译第三方前端项目时候出现Syntax Error: TypeError: Cannot set properties of undefined (setting ‘parent‘)
843 0
|
Ubuntu Linux 编译器
在ubantu/linux系统出现parse error(语法错误)
本文讨论了在Ubuntu/Linux系统中遇到"parse error"(语法错误)的问题,并提供了将非声明语句移动到所有声明语句下方以解决该问题的解决方案。
在ubantu/linux系统出现parse error(语法错误)
|
存储 API Windows
MASM32连接程序时error A2006: undefined symbol : u
MASM32连接程序时error A2006: undefined symbol : u
|
Oracle Java 关系型数据库
Linux下JDK环境的配置及 bash: /usr/local/java/bin/java: cannot execute binary file: exec format error问题的解决
如果遇到"exec format error"问题,文章建议先检查Linux操作系统是32位还是64位,并确保安装了与系统匹配的JDK版本。如果系统是64位的,但出现了错误,可能是因为下载了错误的JDK版本。文章提供了一个链接,指向Oracle官网上的JDK 17 Linux版本下载页面,并附有截图说明。
Linux下JDK环境的配置及 bash: /usr/local/java/bin/java: cannot execute binary file: exec format error问题的解决
|
并行计算 Linux TensorFlow
【Deepin 20系统+Tensorflow 2】Linux系统解决Could not load dynamic library ‘libcudart.so.10.0‘
本文描述了在Deepin 20系统中使用TensorFlow 2时遇到GPU未被利用的问题,并给出了相关的调试日志信息。
142 2
|
Java Linux Shell
【Azure 应用服务】部署Jar到App Service for Linux,因启动命令路径配置错误而引起:( Application Error 问题
【Azure 应用服务】部署Jar到App Service for Linux,因启动命令路径配置错误而引起:( Application Error 问题
140 0
|
Unix Docker 容器
使用docker 启动naocs 报错出现:standard_init_linux.go:241: exec user process caused "exec format error"
```markdown Error in Docker container startup: &quot;standard_init_linux.go:241: exec user process caused \&quot;exec format error\&quot;&quot;. Occurred at 2024-06-29 09:26:19.910, followed by a failed hook with a syslog delivery error at 09:27:20.193. Seeking solutions from experts. ```
|
Oracle Java 关系型数据库
简单记录在Linux上安装JDK环境的步骤,以及解决运行Java程序时出现Error Could not find or load main class XXX问题
本文记录了在Linux系统上安装JDK环境的步骤,并提供了解决运行Java程序时出现的"Error Could not find or load main class XXX"问题的方案,主要是通过重新配置和刷新JDK环境变量来解决。
824 0