Sto lavorando a un progetto in cui devo lavorare con PicoTCP (vedere https://developer.mbed.org/users/daniele/code/PicoTCP/, sto utilizzando una versione precedente di questa libreria). Nel mio file main.cpp, ho il seguente codice:Riferimento non definito a pico_dhcp_server_initiate durante la compilazione di PicoTCP per ARM mbed
#include "pico_stack.h"
#include "pico_dhcp_server.h"
int main(void) {
// create DHCP server
struct pico_dhcpd_settings s = { };
s.my_ip.addr = long_be(0x0a280001); /* 10.40.0.1 */
pico_dhcp_server_initiate(&s);
}
La funzione pico_dhcp_server_initiate
è dichiarata in pico_dhcp_server.h
:
#ifndef _INCLUDE_PICO_DHCP_SERVER
#define _INCLUDE_PICO_DHCP_SERVER
#include "pico_dhcp_common.h"
#include "pico_addressing.h"
... omitted some declarations ...
int pico_dhcp_server_initiate(struct pico_dhcpd_settings *setting);
#endif /* _INCLUDE_PICO_DHCP_SERVER */
E questo metodo è implementato in pico_dhcp_server.c
:
int pico_dhcp_server_initiate(struct pico_dhcpd_settings *setting)
{
...
}
Quando compilo il codice, ottengo il seguente errore: Undefined reference to pico_dhcp_server_initiate(pico_dhcpd_settings *)
. Sto compilando con un Makefile che assomiglia a questo:
# This file was automagically generated by mbed.org. For more information,
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
GCC_BIN =
PROJECT = networking_driver_test
OBJECTS = ./mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_GCC/SVC_Table.o ./mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_GCC/HAL_CM3.o ./USB_Ethernet/modules/pico_dhcp_common.o ./USB_Ethernet/modules/pico_dhcp_client.o ./USB_Ethernet/modules/pico_http_util.o ./USB_Ethernet/modules/pico_ipfilter.o ./USB_Ethernet/modules/pico_nat.o ./USB_Ethernet/modules/pico_udp.o ./USB_Ethernet/modules/pico_igmp.o ./USB_Ethernet/modules/pico_tcp.o ./USB_Ethernet/modules/pico_simple_http.o ./USB_Ethernet/modules/pico_http_client.o ./USB_Ethernet/modules/pico_icmp4.o ./USB_Ethernet/modules/pico_ipv4.o ./USB_Ethernet/modules/pico_dhcp_server.o ./USB_Ethernet/modules/pico_dev_loop.o ./USB_Ethernet/modules/pico_http_server.o ./USB_Ethernet/modules/pico_dns_client.o ./USB_Ethernet/stack/pico_socket.o ./USB_Ethernet/stack/pico_arp.o ./USB_Ethernet/stack/pico_frame.o ./USB_Ethernet/stack/pico_device.o ./USB_Ethernet/stack/pico_tree.o ./USB_Ethernet/stack/pico_stack.o ./USB_Ethernet/stack/pico_protocol.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Event.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_List.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Mutex.o ./mbed-rtos/rtx/TARGET_CORTEX_M/HAL_CM.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Task.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_System.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Time.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_MemBox.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Robin.o ./mbed-rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.o ./mbed-rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.o ./main.o ./USB_Ethernet/USBCDC_ECM.o ./USB_Ethernet/modules/pico_dev_mbed.o ./USB_Ethernet/modules/pico_dev_mbed_usb.o ./USBDevice/USBDevice/USBHAL_RZ_A1H.o ./USBDevice/USBDevice/USBHAL_STM32F4.o ./USBDevice/USBDevice/USBHAL_LPC17.o ./USBDevice/USBDevice/USBHAL_Maxim.o ./USBDevice/USBDevice/USBHAL_LPC11U.o ./USBDevice/USBDevice/USBHAL_LPC40.o ./USBDevice/USBDevice/USBDevice.o ./USBDevice/USBDevice/USBHAL_KL25Z.o ./USBDevice/USBMSD/USBMSD.o ./USBDevice/USBSerial/USBCDC.o ./USBDevice/USBSerial/USBSerial.o ./USBDevice/USBMIDI/USBMIDI.o ./USBDevice/USBHID/USBMouseKeyboard.o ./USBDevice/USBHID/USBKeyboard.o ./USBDevice/USBHID/USBHID.o ./USBDevice/USBHID/USBMouse.o ./USBDevice/USBAudio/USBAudio.o ./mbed-rtos/rtos/Thread.o ./mbed-rtos/rtos/Semaphore.o ./mbed-rtos/rtos/Mutex.o ./mbed-rtos/rtos/RtosTimer.o
SYS_OBJECTS = ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o
INCLUDE_PATHS = -I. -I./USB_Ethernet -I./USB_Ethernet/modules -I./USB_Ethernet/stack -I./USB_Ethernet/include -I./USB_Ethernet/include/arch -I./USBDevice -I./USBDevice/USBDevice -I./USBDevice/USBMSD -I./USBDevice/USBSerial -I./USBDevice/USBMIDI -I./USBDevice/USBHID -I./USBDevice/USBAudio -I./mbed-rtos -I./mbed-rtos/rtos -I./mbed-rtos/rtx -I./mbed-rtos/rtx/TARGET_CORTEX_M -I./mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_M3 -I./mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_GCC -I./mbed -I./mbed/TARGET_LPC1768 -I./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -I./mbed/TARGET_LPC1768/TARGET_NXP -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768
LIBRARY_PATHS = -L./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
LIBRARIES = -lmbed
LINKER_SCRIPT = ./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
###############################################################################
AS = $(GCC_BIN)arm-none-eabi-as
CC = $(GCC_BIN)arm-none-eabi-gcc
CPP = $(GCC_BIN)arm-none-eabi-g++
LD = $(GCC_BIN)arm-none-eabi-gcc
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
SIZE = $(GCC_BIN)arm-none-eabi-size
CPU = -mcpu=cortex-m3 -mthumb
CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer
CC_FLAGS += -MMD -MP
CC_SYMBOLS = -DTARGET_LPC1768 -DTARGET_M3 -DTARGET_CORTEX_M -DTARGET_NXP -DTARGET_LPC176X -DTARGET_MBED_LPC1768 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M3 -DARM_MATH_CM3 -DMBED_BUILD_TIMESTAMP=1432213479.57 -D__MBED__=1
LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main
LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
ifeq ($(DEBUG), 1)
CC_FLAGS += -DDEBUG -O0
else
CC_FLAGS += -DNDEBUG -Os
endif
all: $(PROJECT).bin $(PROJECT).hex
clean:
rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS)
.s.o:
$(AS) $(CPU) -o [email protected] $<
.c.o:
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o [email protected] $<
.cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o [email protected] $<
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o [email protected] $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
@echo ""
@echo "*****"
@echo "***** You must modify vector checksum value in *.bin and *.hex files."
@echo "*****"
@echo ""
$(SIZE) [email protected]
$(PROJECT).bin: $(PROJECT).elf
@$(OBJCOPY) -O binary $< [email protected]
$(PROJECT).hex: $(PROJECT).elf
@$(OBJCOPY) -O ihex $< [email protected]
$(PROJECT).lst: $(PROJECT).elf
@$(OBJDUMP) -Sdh $< > [email protected]
lst: $(PROJECT).lst
size:
$(SIZE) $(PROJECT).elf
DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
-include $(DEPS)
Non sono sicuro di cosa stia causando questo errore. Credo che il file .c non venga compilato in qualche modo ma sono molto nuovo alla sintassi Makefile. Potrebbe essere che ci sia qualcosa di sbagliato nel makefile? Qualcuno può aiutarmi con questo?
Per 'DEBUG', si potrebbe considerare' CC_FLAGS + = -DDEBUG -O1 -g3'. O anche '-Og' nelle versioni successive di GCC perché' -Og' ha lo scopo di eseguire alcune analisi senza influire sull'esperienza di debug. '-O1' richiama l'analisi di base, mentre' -g3' aggiunge le informazioni più debug, comprese le definizioni simboliche. – jww
È interessante, lo proverò sicuramente! – Devos50