Linux gcc编译error:"collect2: ld returned 1 exit status"
2016-06-27 14:03
489 查看
在Linux环境下编一个工程,无论怎么编译总是出现错误,提示如下:
bmeta_info.cpp:4280: undefined reference to `crypt’
collect2: ld returned 1 exit status
网上查的资料表示:
Undefined reference to 错误:这类错误是在连接过程中出现的,可能有两种原因∶一是使用者自己定义的函数或者全局变量所在源代码文件,没有被编译、连接,或者干脆还没有定义,这 需要使用者根据实际情况修改源程序,给出全局变量或者函数的定义体;二是未定义的符号是一个标准的库函数,在源程序中使用了该库函数,而连接过程中还没有 给定相应的函数库的名称,或者是该档案库的目录名称有问题
使用 man crypt命令后从中找到如下信息:
最重要的是最后一句”Programs using this function must be linked with -lcrypt.”,即链接需要加入-lctypt
解决方法:g++ -lcrypt XXXX
【参考:http://blog.sina.com.cn/s/blog_64c238860100wzoo.html】
bmeta_info.cpp:4280: undefined reference to `crypt’
collect2: ld returned 1 exit status
网上查的资料表示:
Undefined reference to 错误:这类错误是在连接过程中出现的,可能有两种原因∶一是使用者自己定义的函数或者全局变量所在源代码文件,没有被编译、连接,或者干脆还没有定义,这 需要使用者根据实际情况修改源程序,给出全局变量或者函数的定义体;二是未定义的符号是一个标准的库函数,在源程序中使用了该库函数,而连接过程中还没有 给定相应的函数库的名称,或者是该档案库的目录名称有问题
使用 man crypt命令后从中找到如下信息:
GNU EXTENSION The glibc2 version of this function has the following additional features. If salt is a character string starting with the three characters "$1$" followed by at most eight characters, and optionally terminated by "$", then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely "$1$<string>$", where "<string>" stands for the up to 8 characters following "$1$" in the salt, followed by 22 bytes chosen from the set [a–zA–Z0–9./]. The entire key is significant here (instead of only the first 8 bytes). Programs using this function must be linked with -lcrypt.
最重要的是最后一句”Programs using this function must be linked with -lcrypt.”,即链接需要加入-lctypt
解决方法:g++ -lcrypt XXXX
【参考:http://blog.sina.com.cn/s/blog_64c238860100wzoo.html】
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- Linux 下无损图片压缩小工具介绍