'Building target: lwip_test_image.elf'
'Invoking: ARM v7 gcc linker'
arm-none-eabi-gcc -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -specs=Xilinx.spec -Wl,-T -Wl,../src/lscript.ld -LD:/AL7020/base/vitis/al7020/export/al7020/sw/al7020/standalone_domain/bsplib/lib -o "lwip_test_image.elf" ./src/interrupt.o ./src/main.o ./src/user_udp.o -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxil,-llwip4,-lgcc,-lc,--end-group
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/interrupt.h:18: multiple definition of `ScuGic'; ./src/interrupt.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/interrupt.h:18: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/interrupt.h:19: multiple definition of `ScuGicCfgPtr'; ./src/interrupt.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/interrupt.h:19: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:23: multiple definition of `netif'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:23: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:23: multiple definition of `server_netif'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:23: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: multiple definition of `ipaddr'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: multiple definition of `netmask'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: multiple definition of `gw'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:25: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:27: multiple definition of `udp_tx_num'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:27: first defined here
c:/xilinx/vitis/2021.1/gnu/aarch32/nt/gcc-arm-none-eabi/x86_64-oesdk-mingw32/usr/bin/arm-xilinx-eabi/../../libexec/arm-xilinx-eabi/gcc/arm-xilinx-eabi/10.2.0/real-ld.exe: ./src/user_udp.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:28: multiple definition of `pkg_cnt'; ./src/main.o:D:\AL7020\base\vitis\lwip_test_image\Debug/../src/user_udp.h:28: first defined here
collect2.exe: error: ld returned 1 exit status
make[1]: *** [makefile:43: lwip_test_image.elf] Error 1
make: *** [makefile:34: all] Error 2
报错提示是头文件重复引用,但是每个头文件内部都添加了防止头文件重复引用的#ifndef #define #endif语句
参考xilinx 支持论坛,是gcc 10版本与以前的版本不兼容的原因
Porting to GCC 10 - GNU Project
根据GNU官方的说明,GCC10开始默认是-fno-common,所以要让编译器回到以前版本的模式,即-fcommon。
Vitis工程中的设置
左边的Explorer中,选中你的application project右键Properties
点击C/C++ Build中的Settings,找到Tool Seetings中的ARM v7 gcc compiler下的Miscellaneous,在Other flags中添加-fcommon,再重新编译即可解决该问题