Replies: 1 comment
-
If linker failed to complete, then it means you have likely forgotten to add some files to the build. Find where your missing symbols are defined (in which file), then go to the cmake build directory and look for "compile_commands.json" file. There are all compilation steps, and make sure that your file is on the list. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Thank you for this tutorial!
I am new to CMake (I always used STM32CubeIDE) and I cannot figure it out how to replicate my setup which is a bit more complex than a single STM project.
My setup is more like this:
I ran the stm32-cube-cmake-vscode.py script against the TITAN_DS project. It created the cmake files and I had to adjust the includes and source files in the cmake_generated.cmake file because the script did not quite get it right, especially because this project references some of the files from the Common Files and Submodules but excludes some from the build. After adjusting the sources_SRCS and include_c_DIRS and symbols_c_SYMB, I ran cmake --build --preset Release. It compiles all the files but when it arrives at the step "Linking C executable TITAN_DS.elf" it fails because it think that he has some undefined reference to xxx (in this case undefined reference to `CPU_SR_Restore'). These are indeed defined, but they are defined in the Submodules folder ( in this case in Submodules/ucos-iii/uC-CPU/ARM-Cortex-M/ARMv7-M/GNU/cpu.h).
I think I am missing something for sure in my setup of cmake. can someone point me in the right direction?
For more context, these are the sources_SRCS and include_c_DIRS I modified:
Sources
set(sources_SRCS ${sources_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/App/Adc/adc.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Communication/CanInterface/Canopen/canopen.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Communication/CanInterface/Canopen/canopen_callbacks.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Communication/CanInterface/canInterface.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Communication/communication.c
${CMAKE_CURRENT_SOURCE_DIR}/App/DebugInterface/Leds/leds.c
${CMAKE_CURRENT_SOURCE_DIR}/App/DebugInterface/TestPoints/testpoints.c
${CMAKE_CURRENT_SOURCE_DIR}/App/DebugInterface/debugInterface.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Digiscope/waveform.c
${CMAKE_CURRENT_SOURCE_DIR}/App/FrequencyMeasurement/frequencyMeasurement.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Monitor/monitor.c
${CMAKE_CURRENT_SOURCE_DIR}/App/Post/post.c
${CMAKE_CURRENT_SOURCE_DIR}/App/System/system.c
${CMAKE_CURRENT_SOURCE_DIR}/App/TestCase/testcase.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Canopen/canopen_Common.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Canopen/canopen_drv.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Canopen/canopen_Emcy.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Event/eventCommon.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/GeneratorConfig/generatorConfig.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/OSError/osError.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Pid/pid.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Post/postCommon.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/SerialInterfaceRS485/serialInterface.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Utils/utils.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Utils/CircularBuffer/circularBuffer.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Utils/Filters/median.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Utils/Queue/queue.c
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Utils/TimeDelay/timeDelay.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Config/ucos-iii/os_app_hooks.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/adc.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/can.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/dma.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/gpio.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/stm32f4xx_hal_msp.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/stm32f4xx_it.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/syscalls.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/sysmem.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/system_stm32f4xx.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/tim.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/usart.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/wwdg.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Startup/startup_stm32f446rctx.s
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_wwdg.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_tim.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_core.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_dict.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_emcy.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_if_can.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_if_nvm.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_if_timer.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_if.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_lss.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_nmt.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_obj.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_para.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_pdo.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_sdo_client.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_sdo_srv.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_sync.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_tmr.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/source/co_ver.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-CPU/cpu_core.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-CPU/ARM-Cortex-M/ARMv7-M/cpu_c.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-LIB/lib_ascii.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-LIB/lib_math.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-LIB/lib_mem.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-LIB/lib_str.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Ports/ARM-Cortex-M/ARMv7-M/os_cpu_c.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_cfg_app.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_core.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_dbg.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_flag.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_mem.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_msg.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_mutex.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_prio.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_q.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_sem.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_task.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_tick.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_time.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_tmr.c
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source/os_var.c
)
Include directories
set(include_c_DIRS ${include_c_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/App
${CMAKE_CURRENT_SOURCE_DIR}/Core/Config/ucos-iii
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-LIB
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-CPU
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Source
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uC-CPU/ARM-Cortex-M/ARMv7-M/GNU
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/ucos-iii/uCOS-III/Ports/ARM-Cortex-M/ARMv7-M/GNU
${CMAKE_CURRENT_SOURCE_DIR}/../Submodules/canopen-stack/canopen/include
${CMAKE_CURRENT_SOURCE_DIR}/../Common\ Files/Canopen/Config
${CMAKE_CURRENT_SOURCE_DIR}/..
)
I tried to replicate as much as possible what I have in STM32CubeIDE project properties.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions