CMake cygwin paths not found by GCC ARM compiler (Mbed example)

Completed

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

  1. CLion uses bundled cmake

  2. CLion uses "CodeBlocks - Unix Makefiles" instead of "Unix Makefiles"

  3. CLion adds /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blink instead of .

  4. CLion writes build files to /cygdrive/c/Users/user/Documents/_tmp/mbed-os-example-blinky/cmake-build-debug instead of C:/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" .

 

 

 

2
7 comments

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.

 

0
Avatar
Permanently deleted user

 

Hi Anna,

Thanks for your response.

 

Have you tried specifying "C:/Users/user/Documents/_tmp/mbed-os-example-blinky" as "Generation Path" in File | Settings | Build, Execution, Deployment | CMake?

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.

C:\Users\jdebruijn\.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/jdebruijn/Documents/_tmp/mbed-os-example-blinky
-- Add a local project.cmake file to add your own targets.
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-gcc.exe
CMAKE_CXX_COMPILER= C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin/arm-none-eabi-g++.exe

-- 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/jdebruijn/Documents/_tmp/mbed-os-example-blinky

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]

 

Please also provide the screenshot File | Settings | Build, Execution, Deployment | Toolchains.

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.


"C:\Program Files\CMake\bin\cmake.exe" -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 "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/jdebruijn/Documents/_tmp/mbed-os-example-blinky
CMake Error: The source directory "/cygdrive/c/Users/jdebruijn/Documents/_tmp/mbed-os-example-blinky" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

[Finished]

 

 

Have you been able to reproduce this issue on a Windows system using the steps described in my first post?

0

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:

  1. After changing the "Generation Path" in File | Settings | Build, Execution, Deployment | CMake please do Tools | CMake | Reset Cache and Reload Project instead of simple reload. Does it help?
  2. If it doesn't help, please install CLion 2018.1 EAP and try it. Is behaviour the same in it?
0
Avatar
Permanently deleted user

Tried both, but same result.

0

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:

arm-none-eabi-gcc.exe: error:
/cygdrive/c/Users/Anna.Falevskaya/CLionProjects/hello_world/cmake-build-debug/CMakeFiles/CMakeTmp/testCCompiler.c:
No such file or directory

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

0
Avatar
Permanently deleted user

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

  1. Download the MinGW get setup from their download page;
  2. Run mingw-get-setup.exe and follow the first installation instructions;
  3. After clicking on Continue in the installation a MinGW Installation Manager opens. Select mingw32-base and click Installation | Apply Changes;
  4. In the window that opens, click Apply to install the selected packages;
  5. After all packages have been successfully installed, click Close and Installation | Quit to close both windows;

Export and configure project

  1. 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
  2. Open CLion and click File | Open… and select mbed-os-example-blinky/mbed-os-example-blinky to open the project;

  3. 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

  4. 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);

  5. Click Apply to save the settings and OK to close the settings window;

  6. 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;

  7. Click Run | Build to compile the project.

0

Jeroen, thanks a lot for letting us know!

0

Please sign in to leave a comment.