I have created two static libraries for use with a C program I am writing for an ARM STM32F4xx processor using Mentor Graphics CodeSourcery. I have added the libraries and their directories to the build settings in the project as I believe they are supposed to be (Under properties, C/C++ Build->Settings->Tool Settings->Sourcery CodeBench C Linker->Libraries) but when I compile and link the project, I get undefined reference errors to functions in one of the libraries. I have tried changing the order of the libraries relative to each other. I have include a snippet below of the compiler log edited to clean up the long path names.

I am at a complete loss here so any help is appreciated.

'Building target: Firmware_Development'
'Invoking: Sourcery CodeBench C Linker'
arm-none-eabi-gcc -L"Libary1-Folder-Path" -L"Library2-Folder-Path" -Xlinker -Map="Firmware_Development.map" -T "firmware-rom-hosted.ld -mcpu=cortex-m4 -mthumb -o "Firmware_Development" "@objs.rsp" "@user_objs.rsp" "@libs.rsp"
src/main.o: In function `program_loop':
\\Debug/../src/main.c:99: undefined reference to `LwIP_Pkt_Handle'
\\Debug/../src/main.c:103: undefined reference to `LwIP_Periodic_Handle'
src/stm32f4xx_it.o: In function `__cs3_isr_exti15_10':
\\Debug/../src/stm32f4xx_it.c:187: undefined reference to `Eth_Link_ITHandler'
src/Config.o: In function `Communication_Init':
\\Debug/../Libraries_Firmware/src/Config.c:175: undefined reference to `ETH_BSP_Config'
\\Debug/../Libraries_Firmware/src/Config.c:178: undefined reference to `LwIP_Init'
collect2.exe: error: ld returned 1 exit status
cs-make: *** [Firmware_Development] Error 1
有帮助吗?

解决方案

For those coming here via searches, the problem was exactly as @ChrisStratton suggested. The code was originally created as a single project and I opted to factor out a large portion of it into a library. When I did this I factored out a header file but missed its corresponding source file so everything compiled fine but failed on link. Checking the objdump made this pretty evident as the objects did not exist.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top