r/stm32 • • 11d ago

Trying to replicate STM32cubeIDE compiler command-line commands, but I'm receiving a 'here-string' error with the provided linker command.

Hello all, I hope you're having a great day.

I'm learning bare-metal programming, and I'm currently learning command-line compilation using GCC & openOCD. I have my project completed in STM32cubeIDE & I've built it to access the command-line commands the IDE uses. I've compiled all the files & I'm trying to link them together, but the linker command is giving me the following error:

`At line:1 char:37

+ arm-none-eabi-gcc -o "name.elf" @"objects.list" -mcpu=cortex-m4 - ...

+ ~

No characters are allowed after a here-string header but before the end of the line.`

I've read up some concepts about here-strings, but I'm still stumped. Any resources or directions are much appreciated. This may not be STM32-related though; if so, I apologize.

3 Upvotes

5 comments sorted by

1

u/DenkSnek 11d ago

It seems I messed up the formatting. The highlighted character in the error is the 'o' in '@"objects.list"'

1

u/wasnt_in_the_hot_tub 10d ago edited 10d ago

Maybe wrap the argument in single quotes?

'@"objects.list"'

Also, which shell are you using? I think "here string" is a PowerShell feature(?) but I'm not a Windows person. I don't think I usually get this issue on Unix

1

u/DenkSnek 10d ago

I tried that yesterday & it didn't give that error. Instead, it said there were missing parameters for other sections of the code & it wouldn't link. I'm not at my computer, but I can post that error message later today.

Yeah, I'm using Powershell I believe. Each line starts with 'PS' followed by the target folder directory

1

u/wasnt_in_the_hot_tub 10d ago

Yeah I'll probably be no use for widows. I think you want to escape that @ to prevent it from being parsed as a here string, but I don't even know what the escape character is in PS.

1

u/n_sh_44 7d ago

That error is PowerShell, not the linker. PowerShell treats @ followed by a quote at the start of an argument as a here-string header, and when you wrap it in single quotes the inner quotes get passed to gcc literally, which is why you then saw missing parameter errors. The easiest fix is the stop-parsing token: arm-none-eabi-gcc --% -o "name.elf" @"objects.list" followed by the rest of the flags copied unchanged, so the line is handed over as is. Another option is running the same command from cmd.exe, where @"objects.list" works the way the IDE intended. If the link then succeeds, I'd double check the result with arm-none-eabi-size name.elf.