Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeSourcery linker errors to static library

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
like image 260
Jared Avatar asked Nov 12 '22 17:11

Jared


1 Answers

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.

like image 113
Jared Avatar answered Nov 14 '22 21:11

Jared