5

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
4

1 回答 1

1

对于那些通过搜索来到这里的人来说,问题与@ChrisStratton 所建议的完全一样。该代码最初是作为单个项目创建的,我选择将其中的大部分内容提取到库中。当我这样做时,我提取了一个头文件,但错过了其相应的源文件,因此一切编译正常,但链接失败。检查 objdump 使这一点非常明显,因为对象不存在。

于 2013-12-12T22:28:46.460 回答