0

What would cause the following Linker Error when compiling C++ XSDK project??

Linker Error Message:

./src/platform/platform_zynq.o: In function `timer_callback(XScuTimer*)':
platform_zynq.c:115:undefined reference to `dhcp_fine_tmr()'

platform_zynq.c:117:undefined reference to `dhcp_coarse_tmr()'

collect2.exe: error: ld returned 1 exit status
make: *** [uartcmd.elf] Error 1

Linker Command as follows:

arm-none-eabi-g++ \
    -mcpu=cortex-a9 \
    -mfpu=vfpv3 \
    -mfloat-abi=hard \
    -Wl,-build-id=none \
    -specs=Xilinx.spec \
    -Wl,-T\
    -Wl,../src/lscript.ld \
    -L../../uartcmd_bsp/ps7_cortexa9_0/lib \
    -o "uartcmd.elf" \
    ./src/platform/platform.o \
    ./src/platform/platform_mb.o \
    ./src/platform/platform_ppc.o \
    ./src/platform/platform_zynq.o \
    ./src/platform/platform_zynqmp.o \
    ./src/fpga_registers2.clang.o \
    ./src/main.o \
    ./src/network.o \
    -Wl,\
    --start-group,-lxil,-lfreertos,-lgcc,-lc,-lstdc++,--end-group\
    -Wl,--start-group,-lxil,-llwip4,-lgcc,-lc,--end-group

Configured Xilinx SDK project as follows:

// Step 0: Create Application Project with FreeRTOS Selected
//
// Step 1: Adding lwIP library to XSDK project.
//
// (2) Right click <app>_bsp and select
// "Board Support Package Settings"
// (3) Click Check box "lwip"
//
// Step 2: Add DHCP Support
// (1) Right click <app>_bsp and select
// "Board Support Package Settings"
// (2) Click Overview:freertos901_xilinx.lwip141
// (3) Check dhcp_options.dhcp_does_arp_check true
// (4) Check dhcp_options.lwip_dhcp true

Symbol Table as Follows:

$ nm ./zynq_rtl.sdk/uartcmd_bsp/ps7_cortexa9_0/lib/liblwip4.a | grep -i dhcp_fine

00001c7c T dhcp_fine_tmr

$ nm ./zynq_rtl.sdk/uartcmd_bsp/ps7_cortexa9_0/lib/liblwip4.a | grep -i dhcp_coarse

00001a54 T dhcp_coarse_tmr

$ nm -C ./uartcmd/Debug/src/platform/platform_zynq.o | grep dhcp_fine

         U dhcp_fine_tmr()

$ nm -C ./uartcmd/Debug/src/platform/platform_zynq.o | grep dhcp_coarse

         U dhcp_coarse_tmr()

Doesn't look like name mangle problem to me... I add "-C" option to prevent demangling of the symbol names...

Bimo
  • 5,987
  • 2
  • 39
  • 61
  • Name mangling problemz? – πάντα ῥεῖ Aug 28 '19 at 18:47
  • how to fix it? add extern "c" to what? – Bimo Aug 28 '19 at 18:50
  • Could be a possible fix, yes. – πάντα ῥεῖ Aug 28 '19 at 18:53
  • I think you are mislabeling... this is not a matching question... I have proven using "nm" that its not a mangle problem... also, I'm using a different toolchain... Xilinx Arm Toolchain for instead of Visual Studio.. – Bimo Aug 28 '19 at 18:55
  • While I see `-L` flag (adds a path), I don't see `-l` to add the `liblwip4` lib. – Ripi2 Aug 28 '19 at 18:56
  • This is what flag "-llwip4 " does... its includes ./zynq_rtl.sdk/uartcmd_bsp/ps7_cortexa9_0/lib/liblwip4.a ... the "lib" prefix is implicit with gcc when using "-l" flag. – Bimo Aug 28 '19 at 18:57
  • Ah, yes, inside `-Wl` flag. Try to change the order of the used libs, if some one depends on another. – Ripi2 Aug 28 '19 at 19:03
  • I found the problem.... its caused because I'm using C++ compiler to compile platform_zynq.c file which was original compile with C compiler... and because the "platform_zynq.c" file is cheating by adding function prototypes into the c file instead of using the proper header file which has it marked as extern "C" linkage... The solution was to comment out the function prototypes in "platform_zynq.c" and to add the correct header file instead: "#include "lwip/dhcp.h" – Bimo Aug 28 '19 at 19:14
  • Post the solution as an answer, and accept it. – Ripi2 Aug 28 '19 at 19:19

0 Answers0