massdns安装的坑

Posted by bfpiaoran on November 21, 2018

 

最近在git上看到一个项目

https://github.com/blechschmidt/massdns

于是下了下来遇到点坑。。。  记下来

clone  之后make的时候

[root@localhost massdns]# make
mkdir -p bin
cc -O3 -std=c11 -DHAVE_EPOLL -DHAVE_SYSINFO -Wall -fstack-protector-strong main.c -o bin/massdns
cc1: error: unrecognized command line option “-std=c11”
cc1: error: unrecognized command line option “-fstack-protector-strong”
make: *** [all] Error 1

报错   查了下是gcc版本低的原因

想yum update下结果yum最高也就到4.4

wget http://people.centos.org/tru/devtools-2/devtools-2.repo
mv devtools-2.repo /etc/yum.repos.d
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

三个安装包(gcc/g++/c++)会被安装到,/opt/rh/devtoolset-2/root/目录中。然后我们创建一个软连接就可以使用了。

ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc
ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++
ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++
gcc –version

之后编译

[root@localhost massdns]# make
mkdir -p bin
cc -O3 -std=c11 -DHAVE_EPOLL -DHAVE_SYSINFO -Wall -fstack-protector-strong main.c -o bin/massdns
/tmp/cc0H3LNe.o: In function `timed_ring_init’:
main.c:(.text+0x4aeb): undefined reference to `clock_gettime’
/tmp/cc0H3LNe.o: In function `timed_ring_add’:
main.c:(.text+0x4d0a): undefined reference to `clock_gettime’
/tmp/cc0H3LNe.o: In function `timed_ring_handle’:
main.c:(.text+0x4e6f): undefined reference to `clock_gettime’
/tmp/cc0H3LNe.o: In function `check_progress’:
main.c:(.text+0x738c): undefined reference to `clock_gettime’
/tmp/cc0H3LNe.o: In function `timed_ring_handle.constprop.22′:
main.c:(.text+0x93c9): undefined reference to `clock_gettime’
/tmp/cc0H3LNe.o:main.c:(.text+0x96a5): more undefined references to `clock_gettime’ follow
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

 

出现clock_gettime 链接错误的问题

 

在Makefile  -lrt即可

 

 

然后make install下成功~~~