5 years, 2 months ago.

CMake and Visual Studio 2017

Cannot get a simple program to link via Visual Studio 2017 using the supplied CMake ARM-GCC. Has anyone gotten this to build succesfully?

Tried the default mbed blinky project, exported it to CMake GCC-Arm, ran with

the following CMakeSettings.Json

CMakeSettings.json

{
	"configurations": [
    {
      "name": "GCC ARM Embedded Release",
      // The syntax for this property is the same as the global one above.
      "generator": "Ninja",
      "configurationType": "Release",
      "inheritEnvironments": [
        "gcc-arm"
      ],
      "buildRoot": "${workspaceRoot}\\build",
      "installRoot": "${workspaceRoot}\\install",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v", 
      "ctestCommandArgs": ""
    }
	]
}

Fails with :

>------ Build started: Project: CMakeLists, Configuration: Release ------ [1/2] C:\PROGRA2\MICROS1\2017\PROFES1\Linux\gcc_arm\bin\arm-none-eabi-g++.exe -DARM_MATH_CM3 -DDEVICE_ANALOGIN=1 -DDEVICE_ANALOGOUT=1 -DDEVICE_CAN=1 -DDEVICE_DEBUG_AWARENESS=1 -DDEVICE_ERROR_PATTERN=1 -DDEVICE_ETHERNET=1 -DDEVICE_I2C=1 -DDEVICE_I2CSLAVE=1 -DDEVICE_INTERRUPTIN=1 -DDEVICE_LOCALFILESYSTEM=1 -DDEVICE_PORTIN=1 -DDEVICE_PORTINOUT=1 -DDEVICE_PORTOUT=1 -DDEVICE_PWMOUT=1 -DDEVICE_RTC=1 -DDEVICE_SEMIHOST=1 -DDEVICE_SERIAL=1 -DDEVICE_SERIAL_FC=1 -DDEVICE_SLEEP=1 -DDEVICE_SPI=1 -DDEVICE_SPISLAVE=1 -DDEVICE_STDIO_MESSAGES=1 -DMBED_BUILD_TIMESTAMP=1550355174.32 -DTARGET_CORTEX -DTARGET_CORTEX_M -DTARGET_LIKE_CORTEX_M3 -DTARGET_LIKE_MBED -DTARGET_LPC1768 -DTARGET_LPC176X -DTARGET_LPCTarget -DTARGET_M3 -DTARGET_MBED_LPC1768 -DTARGET_NXP -DTARGET_RELEASE -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -D__CMSIS_RTOS -D__CORTEX_M3 -D__MBED_CMSIS_RTOS_CM -D__MBED__=1 -Dstart_EXPORTS -I../mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768 -I../mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X -I../mbed/TARGET_LPC1768 -I../mbed -I../. -std=gnu++98 -fno-rtti -Wvla -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m3 -mthumb -include mbed_config.h -O3 -DNDEBUG -MD -MT CMakeFiles/start.dir/main.cpp.obj -MF CMakeFiles\start.dir\main.cpp.obj.d -o CMakeFiles/start.dir/main.cpp.obj -c ../main.cpp

[2/2] cmd.exe /C "cmd.exe /C "cd /D C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start && arm-none-eabi-cpp -E -P -Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r -Wl,--wrap,_realloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,_calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n -mcpu=cortex-m3 -mthumb mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld -o C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start_pp.link_script.ld && cd C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start\build" && C:\PROGRA2\MICROS1\2017\PROFES1\Linux\gcc_arm\bin\arm-none-eabi-g++.exe -std=gnu++98 -fno-rtti -Wvla -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m3 -mthumb -include mbed_config.h -O3 -DNDEBUG -Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,__malloc_r -Wl,--wrap,__free_r -Wl,--wrap,__realloc_r -Wl,--wrap,__memalign_r -Wl,--wrap,__calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n -mcpu=cortex-m3 -mthumb -LC:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed -Wl,--end-group -T C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start_pp.link_script.ld CMakeFiles/start.dir/main.cpp.obj -o start -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys && cmd.exe /C "cd /D C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start\build && arm-none-eabi-objcopy -O ihex C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start.hex && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E echo "-- built: C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start.hex"""

FAILED: start start_pp.link_script.ld

cmd.exe /C "cmd.exe /C "cd /D C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start && arm-none-eabi-cpp -E -P -Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r -Wl,--wrap,_realloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,_calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n -mcpu=cortex-m3 -mthumb mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld -o C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start_pp.link_script.ld && cd C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start\build" && C:\PROGRA2\MICROS1\2017\PROFES1\Linux\gcc_arm\bin\arm-none-eabi-g++.exe -std=gnu++98 -fno-rtti -Wvla -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -g1 -mcpu=cortex-m3 -mthumb -include mbed_config.h -O3 -DNDEBUG -Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,__malloc_r -Wl,--wrap,__free_r -Wl,--wrap,__realloc_r -Wl,--wrap,__memalign_r -Wl,--wrap,__calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n -mcpu=cortex-m3 -mthumb -LC:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed -Wl,--end-group -T C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start_pp.link_script.ld CMakeFiles/start.dir/main.cpp.obj -o start -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys && cmd.exe /C "cd /D C:\Users\alees\Downloads\start_cmake_gcc_arm_lpc1768\start\build && arm-none-eabi-objcopy -O ihex C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start.hex && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E echo "-- built: C:/Users/alees/Downloads/start_cmake_gcc_arm_lpc1768/start/build/start.hex"""

'cmd.exe' is not recognized as an internal or external command, operable program or batch file. ninja: build stopped: subcommand failed. Build failed.

1 Answer

5 years, 2 months ago.

Hi Andrew, some time ago I did some tests with Visual Studio 2015 that looked interesting and did work.

This was with some help from this guy:

https://platformio.org/

He was very helpful setting it up for Visual Studio.

Looking at his web site now looks like it moved on a bit and may be interesting trying again.

I have tried all sorts of off line and 'something different to Mbed' options but in the end I always come back to on-line Mbed. providing you have internet connection, who hasn't, and mine is only GPRS as I live in rustic farmland country. However it still remains the only way I can get access to the Keil compiler that is probably the best out there.

Might give platformio a go though :)

Accepted Answer

Thank you very much, will have a go at this when I get exhausted looking into other avenues first. Also found this blog post very helpful ARM GCC Cross Compilation in Visual Studio.

Still having troubles with the linker at this point.

posted by Andrew Leesing 20 Feb 2019