Closed FOSquare closed 5 years ago
FOSquare notifications@github.com writes:
Hello, I follow the tuturial, after I install dependencies correctly. I compile the program by "make" in the folder of /xdp-tutorial, but I have the following errors. Thanks.
Did you run 'git submodule init' and 'git submodule update' ?
Yes, and I could find that libbpf was successfully added in the repository.
Same error as I run on another server. Could you help me? Thanks. My OS is Ubuntu 16.04.6 LTS \n \l
make[1]: Entering directory '/home/fyan/xdp-tutorial/libbpf/src' cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c bpf.c -o bpf.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c btf.c -o btf.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c libbpf.c -o libbpf.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c libbpf_errno.c -o libbpf_errno.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c netlink.c -o netlink.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c nlattr.c -o nlattr.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c str_error.c -o str_error.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c libbpf_probes.c -o libbpf_probes.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c bpf_prog_linfo.c -o bpf_prog_linfo.o cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibil ity=hidden -g -O2 -Werror -Wall -c xsk.c -o xsk.o ar rcs libbpf.a bpf.o btf.o libbpf.o libbpf_errno.o netlink.o nlattr.o str_error .o libbpf_probes.o bpf_prog_linfo.o xsk.o cc -shared -lelf -Wl,--version-script=libbpf.map \ -Wl,-soname,libbpf.so.0 \ bpf.o btf.o libbpf.o libbpf_errno.o netlink.o nlatt r.o str_error.o libbpf_probes.o bpf_prog_linfo.o xsk.o -o libbpf.so.0.0.3 ln -sf libbpf.so.0.0.3 libbpf.so.0 ln -sf libbpf.so.0 libbpf.so sed -e "s|@PREFIX@|/usr|" \ -e "s|@LIBDIR@|/usr/lib64|" \ -e "s|@VERSION@|0.0.3|" \ < libbpf.pc.template > libbpf.pc make[1]: Leaving directory '/home/fyan/xdp-tutorial/libbpf/src' make[1]: Entering directory '/home/fyan/xdp-tutorial/libbpf/src' if [ ! -d 'root/usr/include/bpf' ]; then install -d -m 755 'root/usr/include/bpf '; fi; install bpf.h libbpf.h btf.h -m 644 'root/usr/include/bpf' make[1]: Leaving directory '/home/fyan/xdp-tutorial/libbpf/src' make -C ../common/ make[1]: Entering directory '/home/fyan/xdp-tutorial/common' gcc -g -Wall -I../libbpf/src//root/usr/include/ -c -o common_params.o common_par ams.c common_params.c: In function ‘parse_cmdline_args’: common_params.c:113:23: error: ‘XDP_FLAGS_MODES’ undeclared (first use in this f unction) cfg->xdp_flags &= ~XDP_FLAGS_MODES; / Clear flags / ^ common_params.c:113:23: note: each undeclared identifier is reported only once f or each function it appears in common_params.c:117:22: error: ‘XDP_FLAGS_SKB_MODE’ undeclared (first use in thi s function) cfg->xdp_flags |= XDP_FLAGS_SKB_MODE; / Set flag / ^ common_params.c:121:22: error: ‘XDP_FLAGS_DRV_MODE’ undeclared (first use in thi s function) cfg->xdp_flags |= XDP_FLAGS_DRV_MODE; / Set flag / ^ common_params.c:125:22: error: ‘XDP_FLAGS_HW_MODE’ undeclared (first use in this function) cfg->xdp_flags |= XDP_FLAGS_HW_MODE; / Set flag / ^ common_params.c:128:23: error: ‘XDP_FLAGS_UPDATE_IF_NOEXIST’ undeclared (first u se in this function) cfg->xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST; ^ Makefile:13: recipe for target 'common_params.o' failed make[1]: [common_params.o] Error 1 make[1]: Leaving directory '/home/fyan/xdp-tutorial/common' ../common//common.mk:100: recipe for target '../common//common_params.o' failed make: [../common//common_params.o] Error 2
FOSquare notifications@github.com writes:
I try to run it in another server. still met problem. The same procedures as shown in the toturial. the kernel version is 4.15.0-20-generic. Thanks.
Hmm, it may just be that your kernel headers are too old. You are going to need a newer kernel to run the examples anyway, at least 4.19.
Since you're on Ubuntu, you should be able to get a newer kernel package (and headers) from the kernel-ppa at https://kernel.ubuntu.com/~kernel-ppa/mainline/
I faced this same problem as FOSquare on my desktop with Ubuntu 19.04 "kernel 5.0.0-13-generic". My ubuntu packages include the following :
$ dpkg -l | grep linux- ii binutils-x86-64-linux-gnu 2.32-7ubuntu4 amd64 GNU binary utilities, for x86-64-linux-gnu target ii linux-base 4.5ubuntu1 all Linux image base package ii linux-firmware 1.178.1 all Firmware for Linux kernel drivers ii linux-generic 5.0.0.13.14 amd64 Complete Generic Linux kernel and headers ii linux-headers-5.0.0-13 5.0.0-13.14 all Header files related to Linux kernel version 5.0.0 ii linux-headers-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel headers for version 5.0.0 on 64 bit x86 SMP ii linux-headers-generic 5.0.0.13.14 amd64 Generic Linux kernel headers ii linux-image-5.0.0-13-generic 5.0.0-13.14 amd64 Signed kernel image generic ii linux-image-generic 5.0.0.13.14 amd64 Generic Linux kernel image ii linux-libc-dev:amd64 5.0.0-15.16 amd64 Linux Kernel Headers for development ii linux-modules-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel extra modules for version 5.0.0 on 64 bit x86 SMP ii linux-modules-extra-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel extra modules for version 5.0.0 on 64 bit x86 SMP ii linux-source 5.0.0.15.16 all Linux kernel source with Ubuntu patches ii linux-source-5.0.0 5.0.0-15.16 all Linux kernel source for version 5.0.0 with Ubuntu patches ii linux-tools-5.0.0-13 5.0.0-13.14 amd64 Linux kernel version specific tools for version 5.0.0-13 ii linux-tools-5.0.0-13-generic 5.0.0-13.14 amd64 Linux kernel version specific tools for version 5.0.0-13 ii linux-tools-common 5.0.0-15.16 all Linux kernel version specific tools for version 5.0.0
I followed setup_dependencies.org, and the dependencies of this tutorial has been correctly done.
Maybe I think that update of "xdp_tutorial/headers" directory is one of cause of this compile error.
Currenty, I modify clang command area in common/common.mk
to add -I/usr/include/x86_64-linux-gnu/
line, then I can compile "basic01" program.
By downloading and installing: linux-headers-4.20.0-042000_4.20.0-042000.201812232030_all.deb linux-image-unsigned-4.20.0-042000-generic_4.20.0-042000.201812232030_amd64.deb linux-modules-4.20.0-042000-generic_4.20.0-042000.201812232030_amd64.deb
I update my kernel version to 4.20.0-042000-generic. I still have the same problem....
Thanks.
what do you mean by adding -I/usr/include/x86_64-linux-gnu/ line in common.mk? I tried, but after I added "-I /usr/include/x86_64-linux-gnu/" in the common.mk. I have ./common//common.mk:13: *** missing separator. Stop.
Thanks.
Right, with the latest batch of changes you should at least be able to compile things even on old Ubuntu installs. Whether or not the result actually works is a different matter, but do try it out ;)
Hi, @tohojo and @FOSquare !
Add '-I/usr/include/x86_64-linux-gnu' is just a temporary walk-around solution! Please try:
sudo apt-get install -y gcc-multilib
Then revert commit 77edd02.
The gcc-multilib debian package makes a symbol link at "/usr/include/asm" to "/usr/include/x86_64-linux-gnu"
Hello, I follow the tuturial, after I install dependencies correctly. I compile the program by "make" in the folder of /xdp-tutorial, but I have the following errors. Thanks.
make -C basic03-map-counter make[1]: Entering directory '/home/fyan/xdp-tutorial/basic03-map-counter' make -C ../common/ make[2]: Entering directory '/home/fyan/xdp-tutorial/common' gcc -g -Wall -I../libbpf/src//root/usr/include/ -c -o common_params.o common_params.c common_params.c: In function ‘parse_cmdline_args’: common_params.c:113:23: error: ‘XDP_FLAGS_MODES’ undeclared (first use in this function) cfg->xdp_flags &= ~XDP_FLAGS_MODES; / Clear flags / ^ common_params.c:113:23: note: each undeclared identifier is reported only once for each function it appears in common_params.c:117:22: error: ‘XDP_FLAGS_SKB_MODE’ undeclared (first use in this function) cfg->xdp_flags |= XDP_FLAGS_SKB_MODE; / Set flag / ^ common_params.c:121:22: error: ‘XDP_FLAGS_DRV_MODE’ undeclared (first use in this function) cfg->xdp_flags |= XDP_FLAGS_DRV_MODE; / Set flag / ^ common_params.c:125:22: error: ‘XDP_FLAGS_HW_MODE’ undeclared (first use in this function) cfg->xdp_flags |= XDP_FLAGS_HW_MODE; / Set flag / ^ common_params.c:128:23: error: ‘XDP_FLAGS_UPDATE_IF_NOEXIST’ undeclared (first use in this function) cfg->xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST; ^ Makefile:13: recipe for target 'common_params.o' failed make[2]: [common_params.o] Error 1 make[2]: Leaving directory '/home/fyan/xdp-tutorial/common' ../common//common.mk:100: recipe for target '../common//common_params.o' failed make[1]: [../common//common_params.o] Error 2 make[1]: Leaving directory '/home/fyan/xdp-tutorial/basic03-map-counter' Makefile:12: recipe for target 'basic03-map-counter' failed make: *** [basic03-map-counter] Error 2