Home > Back-end >  bad defsym; format is --defsym name=value
bad defsym; format is --defsym name=value

Time:06-18

Explanation: I've created an STM32 project and aim to get a platform-independent build and output file like .hex, .bin, and .elf. For this, I created the project under the CMake build system. CMake configuration settings and toolchain settings have been made. However, towards the end of the build phase, I encountered this error.

Linker flags: Under "compiler_flags.cmake" file.

...

set(LD_FLAGS "-Wl,-Map=${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map,--cref -T${LD_SCRIPT} -Wl,--gc-sections -static,--specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wl,--defsym,__cxa_pure_virtual=1 -Wl,--start-group -lc -lm -Wl,--end-group")

Error output:

...
...
...

Assembler messages:
Fatal error: bad defsym; format is --defsym name=value
ninja: build stopped: subcommand failed.

CodePudding user response:

Your LDFLAGS have mistakes:

  • there should be no whitespace in -Wl, --gc-sections
  • -defsym ... __cxa_pure_virtual=1 should be changed to -Wl,--defsym,__cxa_pure_virtual=1

CodePudding user response:

The source of the error was in the assembler compiler toolchain definition. The problem was solved by typing arm-none-eabi-gcc.exe instead of arm-none-eabi-as.exe.

  • Related