CMake cygwin paths not found by GCC ARM compiler (Mbed example)
System information
-
Windows 10 [Version 10.0.16299.248]
-
CMake (system version) 3.10.2 (installed using from CMake as Windows win64-x64 installer)
-
Compiler (for Mbed appication) GNU ARM Embedded toolchain 6.3.1 20170620
- CLion 2017.3.3
Problem
I'm trying to build a mbed example application in CLion. Mbed exports the project for CMake, which I am able to compile using the commands described in Working version without CLion below. See below and please let me know if I need to provide more information. I hope someone can help me here before creating a ticket.
PS This problem does not exist with a similar setup on macOS
Steps to reproduce problem
$ mbed import mbed-os-example-blinky
[mbed] Importing program "mbed-os-example-blinky" from "https://github.com/ARMmbed/mbed-os-example-blinky" at latest revision in the current branch
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at rev #569159b784f7
[mbed] Auto-installing missing Python modules...
$ cd mbed-os-example-blinky
$ mbed export -i cmake_gcc_arm -m NUCLEO_F103RB
Scan: .
Open the project in CLion (File > Open...) and CLion initialises the project by calling cmake, see CLion output below.
C:\Users\user\.CLion2017.3\system\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_C_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-g++.exe" -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky
-- The C compiler identification is GNU 6.3.1
-- The CXX compiler identification is GNU 6.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Add a local project.cmake file to add your own targets.
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky/cmake-build-debug
Problems were encountered while collecting compiler information:
Unexpected compiler output. This compiler might be unsupported.
If you are using GCC/Clang, please report the bug in https://youtrack.jetbrains.com/issues/CPP.
[Finished]
Now the program should be ready to build, but building generates the following issue. The problem I see is that it tries to use /cygdrive path but the GCC ARM compiler can not find those since they're cygwin paths.
C:\Users\user\.CLion2017.3\system\cygwin_cmake\bin\cmake.exe --build C:\Users\user\Documents\_tmp\mbed-os-example-blinky\cmake-build-debug --target mbed-os-example-blinky -- -j 2
Scanning dependencies of target mbed-os-example-blinky
[ 0%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/main.cpp.obj
[ 0%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/AnalogIn.cpp.obj
arm-none-eabi-g++.exe: error: /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky/main.cpp: No such file or directory
arm-none-eabi-g++.exe: fatal error: no input files
compilation terminated.
make[3]: *** [CMakeFiles/mbed-os-example-blinky.dir/build.make:63: CMakeFiles/mbed-os-example-blinky.dir/main.cpp.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
arm-none-eabi-g++.exe: error: /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky/mbed-os/drivers/AnalogIn.cpp: No such file or directory
arm-none-eabi-g++.exe: fatal error: no input files
compilation terminated.
make[3]: *** [CMakeFiles/mbed-os-example-blinky.dir/build.make:87: CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/AnalogIn.cpp.obj] Error 1
make[2]: *** [CMakeFiles/Makefile2:100: CMakeFiles/mbed-os-example-blinky.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/mbed-os-example-blinky.dir/rule] Error 2
make: *** [Makefile:131: mbed-os-example-blinky] Error 2
Working version without CLion
However, running the following after the first section works.
$ cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:/cygwin64/bin/make.exe "-DCMAKE_C_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-g++.exe" -G "Unix Makefiles" . -- The C compiler identification is GNU 6.3.1 -- The CXX compiler identification is GNU 6.3.1 -- The ASM compiler identification is GNU -- Found assembler: C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Detecting C compile features -- Detecting C compile features - failed -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Detecting CXX compile features -- Detecting CXX compile features - failed -- Add a local project.cmake file to add your own targets. -- Configuring done -- Generating done -- Build files have been written to: C:/Users/user/Documents/_tmp/mbed-os-example-blinky $ make all Scanning dependencies of target mbed-os-example-blinky [ 0%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/main.cpp.obj [ 0%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/AnalogIn.cpp.obj [ 1%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/BusIn.cpp.obj [ 1%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/BusInOut.cpp.obj [ 1%] Building CXX object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/drivers/BusOut.cpp.obj ... [ 99%] Building C object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/targets/TARGET_STM/us_ticker_16b.c.obj [ 99%] Building C object CMakeFiles/mbed-os-example-blinky.dir/mbed-os/targets/TARGET_STM/us_ticker_32b.c.obj [100%] Linking CXX executable mbed-os-example-blinky -- built: C:/Users/user/Documents/_tmp/mbed-os-example-blinky/mbed-os-example-blinky.hex [100%] Built target mbed-os-example-blinky
Difference with and without CLion
-
CLion uses bundled cmake
-
CLion uses
"CodeBlocks - Unix Makefiles"
instead of"Unix Makefiles"
-
CLion adds
/cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blink
instead of.
-
CLion writes build files to
/cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky/cmake-build-debug
instead ofC:/Users/user/Documents/_tmp/mbed-os-example-blinky
What I have tried
Changing the CLion Settings of the project to have CMake options as follows doesn't make a difference since CLion still adds -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky
to the options.
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:/cygwin64/bin/make.exe "-DCMAKE_C_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-g++.exe" -G "Unix Makefiles" .
Please sign in to leave a comment.
Hi, Jeroen!
Have you tried specifying "C:/Users/user/Documents/_tmp/mbed-os-example-blinky" as "Generation Path" in File | Settings | Build, Execution, Deployment | CMake? Please also provide the screenshot File | Settings | Build, Execution, Deployment | Toolchains.
Hi Anna,
Thanks for your response.
Just tried this with no result. Changed the generation path and clicked Reload CMake project (right click on project). In de console log below it shows that it still uses the
/cygdrive/...
path.Please see the image below. I've also tried specifying the CMake to use (see top of previous post), but that resulted in another failure (i think due to the CMake version not being supported as there is a warning in the Toolchains window when I change it.
Have you been able to reproduce this issue on a Windows system using the steps described in my first post?
Thanks for the info. I will try to reproduce the issue, but it will take some time. Meanwhile I kindly ask you to try these two things:
Tried both, but same result.
Dear Jeroen, sorry for the delay.
Actually, on my side it fails even earlier, at the Check for working C compiler: C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe stage, but with the similar error:
It seems to me that the arm-none-eabi-gcc.exe compiler doesn't understand cygwin paths. The following stackoverflow topic looks related: https://stackoverflow.com/questions/28927088/arm-gcc-with-cygwin-on-windows-8-1-fatal-error-no-input-file
Hi Anna,
Thanks for your time and effort looking into this!
I ended up using MinGW and it works perfectly now, because MinGW uses Windows paths which the GCC ARM compiler understands.
Steps I took to get CLion setup for this program:
Installation
Install MinGW
mingw-get-setup.exe
and follow the first installation instructions;Continue
in the installation a MinGW Installation Manager opens. Selectmingw32-base
and click Installation | Apply Changes;Export and configure project
Open a terminal in the project folder (
mbed-os-example-blinky/mbed-os-example-blinky
) and export the project for a specific target;$ mbed export -i cmake_gcc_arm -m NUCLEO_F103RB
Open CLion and click File | Open… and select
mbed-os-example-blinky/mbed-os-example-blinky
to open the project;In File | Settings | Build, Execution, Deployment | Toolchains click the + sign to add a new toolchain and make the required settings; Name:
ARM
Environment:MinGW
C:\MinGW
CMake:Bundled
Make:C:\MinGW\bin\mingw32-make.exe
C Compiler:C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin\arm-none-eabi-gcc.exe
C++ Compiler:C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin\arm-none-eabi-g++.exe
Debugger:C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin\arm-none-eabi-gdb.exe
Click the blue arrow to set the newly created
ARM
toolchain to the top in the list of toolchains. It will be suffixed with(default)
;Click Apply to save the settings and OK to close the settings window;
Give CLion some time to reload the CMake project. The status bar in the bottom will show the progress but can take a couple of minutes;
Click Run | Build to compile the project.
Jeroen, thanks a lot for letting us know!