树莓派raspberry编译isc-dhcp遇到“undefined reference to `__atomic_fetch_add_8'”错误
想在树莓派上修改dhclient,增加一些打印信息,需要编译isc-dhcp。
但是在编译过程中遇到了一个错误,错误如下:
1 gcc -g -Wall -Werror -fno-strict-aliasing -I../includes -I/home/pi/dhcp-4.4.3-P1/bind/include -o dhcrelay dhcrelay.o ../common/libdhcp.a ../omapip/libomapi.a /home/pi/dhcp-4.4.3-P1/bind/lib/libirs.a /home/pi/dhcp-4.4.3-P1/bind/lib/libdns.a /home/pi/dhcp-4.4.3-P1/bind/lib/libisccfg.a /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a 2 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `incrementcounter': 3 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:226: undefined reference to `__atomic_fetch_add_8' 4 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `decrementcounter': 5 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:249: undefined reference to `__atomic_fetch_sub_8' 6 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `getcounter': 7 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:266: undefined reference to `__atomic_load_8' 8 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `setcounter': 9 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:286: undefined reference to `__atomic_store_8' 10 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `isc_stats_update_if_greater': 11 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:426: undefined reference to `__atomic_load_8' 12 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:433: undefined reference to `__atomic_compare_exchange_8' 13 /usr/bin/ld: /home/pi/dhcp-4.4.3-P1/bind/lib/libisc.a(stats.o): in function `getcounter': 14 /home/pi/dhcp-4.4.3-P1/bind/bind-9.11.36/lib/isc/stats.c:266: undefined reference to `__atomic_load_8' 15 collect2: error: ld returned 1 exit status 16 make[2]: *** [Makefile:447: dhcrelay] Error 1 17 make[2]: Leaving directory '/home/pi/dhcp-4.4.3-P1/relay' 18 make[1]: *** [Makefile:527: all-recursive] Error 1 19 make[1]: Leaving directory '/home/pi/dhcp-4.4.3-P1/relay' 20 make: *** [Makefile:463: all-recursive] Error 1
这个是在编译replay子目录时出错,需要修改replay/Makefile文件,增加-latomic链接即可:
BINDSRCDIR =
BINDSUBDIR =
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -latomic -Wall -Werror -fno-strict-aliasing -I$(top_srcdir)/includes -I/home/pi/dhcp-4.4.3-P1/bind/include
CPPFLAGS =
CSCOPE = cscope
CTAGS = ctags
修改完成之后,再make就通过了。
不过还有其他子目录也会出现相同的错误,参照这个方法就能修改对应目录下的Makefile文件即可。