最近在编译一个开源项目时,遇到这个编译错误:
fatal error: 'libelf.h' file not found
#include <libelf.h>
^
1 error generated.
解决方法是安装elfutils-libelf-devel
这个软件包:
yum install elfutils-libelf-devel
或:
dnf install elfutils-libelf-devel
最近在编译一个开源项目时,遇到这个编译错误:
fatal error: 'libelf.h' file not found
#include <libelf.h>
^
1 error generated.
解决方法是安装elfutils-libelf-devel
这个软件包:
yum install elfutils-libelf-devel
或:
dnf install elfutils-libelf-devel
EPEL网站提供了clang
的RPM
安装包,所以要想在CentOS 7
安装clang
,首先需要安装EPEL
包:
sudo yum install epel-release
接下来安装 clang
:
sudo yum install clang
然后就可以使用clang
了。
今天看到一篇文章,作者通过一个shell
脚本和一个Makefile
,可以自动下载需要的所有安装包并且编译gcc
:
$ # Download the scripts using wget.
$ mkdir /opt/gcc-4.9.2
$ cd /opt/gcc-4.9.2
$ wget http://projects.joelinoff.com/gcc-4.9.2/bld.sh
$ wget http://projects.joelinoff.com/gcc-4.9.2/Makefile
$ chmod a+x bld.sh
$ make
[output snipped]
$ # The compiler is installed in /opt/gcc-4.9.2/rtf/bin
我试了一下,果然很方便。只要有一台可以联网的机器就可以了。感兴趣的朋友可以试一试。
P.S.:
(1)编译libiconv
时可能会有“'gets' undeclared here
“错误,请参考这篇文章。
(2)如果机器是64
位的,但是缺少32
位的库文件。这样在编译gcc
时会出现错误:“configure: error: I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with –enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with –disable-multilib.”。提示需要配置“--disable-multilib
”。
前几天安装最新的gdb
过程中出了点问题,想卸载一下。结果执行“make uninstall
”命令后,出现下面的结果:
bash-3.2# make uninstall
the uninstall target is not supported in this tree
看起来,gdb
不支持直接用“make uninstall
”命令卸载,那么如何卸载它呢?我在gdb mailing list
里问了一下,收到了Doug Evans
的回信:
Yikes.
A clumsy workaround is to cd into each subdir in the build tree and do
make uninstall there.
只能是进入每个子目录,分别执行“make uninstall
”命令了。
后来,他又在一封单独的信中提到,他已经提交了bug,看看会不会有人做一下改进了。
最近在Solaris
上编译一款开源软件,在最后链接阶段出了问题,导致ld
程序core dump
。由于没有ld
程序源代码,导致完全没思路,没办法,只好在stackoverflow
上求教:http://stackoverflow.com/questions/26009192/why-the-ld-crash-in-building-libgd。从回复中我才知道可以通过设置LD_OPTIONS
环境变量,来了解整个链接过程。举个例子:
LD_OPTIONS=-Dfiles,detail
指定files
会输出ld
当前处理的文件,detail
会提供更多的信息。
可以用“ld -Dhelp
”命令打印每个选项的详细帮助信息。
如果想详细了解Solaris
下程序的链接过程,可以参考这篇文档:Linker and Libraries Guide。