STM32 - need help configuring linker under eclipse

It has been 10 years since I did C/C++ last time so I am totally missing the compiler vs linker phases.

I am running eclipse with the arm plugin with Sourcery as compiler/linker. Trying to use device libraries but linker fails. (compiler has found everything - I guess I have provided all the paths to all the .h files)

Linker should be linking some compiled stuff, right? Where do I take compiled library then? All I see in the Libraries folder are .c and .h files. So, how do I get any library binaries I would be linking to my stuff?

Here is my output:

‘Building file: …/myclass.cpp’

‘Invoking: ARM Sourcery Windows GCC C++ Compiler’

arm-none-eabi-g++ -I"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\STM32F4xx_StdPeriph_Driver\inc" -I"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\ST\STM32F4xx\Source\Templates" -I"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\Include" -I"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\ST\STM32F4xx\Include" -I"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\STM32F4xx_StdPeriph_Driver\src" -O0 -Wall -Wa,-adhlns=“myclass.o.lst” -fno-exceptions -fno-rtti -c -fmessage-length=0 -MMD -MP -MF"myclass.d" -MT"myclass.d" -mcpu=cortex-m4 -mthumb -g3 -gdwarf-2 -o “myclass.o” “…/myclass.cpp”

‘Finished building: …/myclass.cpp’

’ ’

‘Building target: tft2.elf’

‘Invoking: ARM Sourcery Windows GCC C++ Linker’

arm-none-eabi-g++ -T"C:\Documents and Settings\andrey\workspace\tft2\stm32_flash.ld" -L"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries" -L"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\STM32F4xx_StdPeriph_Driver\src" -L"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\Include" -L"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\ST\STM32F4xx\Source\Templates" -L"C:\stuff\STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\ST\STM32F4xx\Include" -Wl,-Map,tft2.map -mcpu=cortex-m4 -mthumb -g3 -gdwarf-2 -o “tft2.elf” ./LibraryHacks.o ./MillisecondTimer.o ./myclass.o

c:/program files/codesourcery/sourcery_codebench_lite_for_arm_eabi/bin/…/lib/gcc/arm-none-eabi/4.6.3/…/…/…/…/arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol Reset_Handler; defaulting to 08000000

./MillisecondTimer.o: In function `myn::MillisecondTimer::initialise()':

C:\Documents and Settings\andrey\workspace\tft2\Debug/…/MillisecondTimer.cpp:33: undefined reference to `SystemCoreClock’

C:\Documents and Settings\andrey\workspace\tft2\Debug/…/MillisecondTimer.cpp:33: undefined reference to `SystemCoreClock’

collect2: ld returned 1 exit status

cs-make: *** [tft2.elf] Error 1

Look in the file MillisecondTimer.cpp. You are using a reference to a label SystemCoreClock. That label is not found in any of the object librarys. You will need to find where that object file is. Another probel is that you are not specifying an entry point Reset_Handler. Some of the lower level entry points are actually defined in a linker script which is unique to the particular processor you are using.

Hi Russian,

I know you’re looking for help on how to use Eclipse and the Arm plug in, rather than advice not to use them but… ugh.

I just think you can get that first project built more quickly and with less confusion if you do it first with an old-fashioned Makefile. Once you’re able to build it that way, you can bring it into Eclipse by creating a Makefile project. In fact, that is the only way I’ve been using Eclipse. I’m sure there is documentation somewhere on exactly what the plug-ins do and how to configure them, but it takes more digging than I’ve been willing to do.

Eclipse is free but a bear to understand and get working.

Does ST have a free IDE tool like Atmel has with Studio 6?

Or you could use a free demo version of IAR’s compiler/IDE so long as the code size limit is OK. It’s like 32KB if I recall correctly, for ARMs. Perhaps Keil has the same.

failing that, perhaps install generic WinARM, then get a sample project for a similar ST, and go from there.

am successfully running the same toolchain under kubuntu 12.04, took me a while to figure out how to do so, but ok by now except a few smaller issues… please provide your demo project and let me see if I can get it compiled and working… btw am using stm32f4-discovery, with hardware debugging via eclipse and stlinkv2… what is your target system? better also look for some linker scripts and initialization files there, guess that’s what’s missing in your case…

Thank you everyone for the input!

So, first of all it has turned out I am responsible for defining the SystemCoreClock constant. And 2nd thing - I was supposed to specify linked script file name as linker setting in Eclipse. This is still a bit of voodoo magic, but I am moving forward :slight_smile: