ZeroTier是个很好的虚拟局域网工具,但直接交叉编译到ARM开发板的时候存在一些问题,花了点时间解决,做一下记录。
项目地址:https://github.com/zerotier/ZeroTierOne
下载解压以后,修改make-linux.mk,直接注释编译器的判断部分,加上自己的交叉编译器
# Automagically pick CLANG or RH/CentOS newer GCC if present
# This is only done if we have not overridden these with an environment or CLI variable
#ifeq ($(origin CC),default)
# CC:=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
# CC:=$(shell if [ -e /opt/rh/devtoolset-8/root/usr/bin/gcc ]; then echo /opt/rh/devtoolset-8/root/usr/bin/gcc; else echo $(CC); fi)
#endif
#ifeq ($(origin CXX),default)
# CXX:=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
# CXX:=$(shell if [ -e /opt/rh/devtoolset-8/root/usr/bin/g++ ]; then echo /opt/rh/devtoolset-8/root/usr/bin/g++; else echo $(CXX); fi)
#endif
CC:=arm-linux-gnueabihf-gcc
CXX:=arm-linux-gnueabihf-g++
直接make以后放到设备上运行,报错如下:
pure virtual method called
terminate called without an active exception
Aborted
再次运行就直接Segmentation fault了,研究了下发现是.mk没有正确设置arch,于是把mk文件里的-march=armv5全部换成-march=armv7-a,这回再运行终于显示了真正错误的原因:
ERROR: unable to configure virtual network port: could not open TUN/TAP device: No such file or directory
去内核make menuconfig,勾选Network core driver support->Universal TUN/TAP device driver support,
重新编译烧录内核,这下终于可以顺利执行zerotier-one -d命令了,接着执行/zerotier-cli join < network id >就可加入网络了,enjoy!