cross-compiling not working on Windows
The README says that cross-compiling works on Windows without a virtual machine using the MentorGraphics toolchain. But I am struggling to get it working on my Windows machine. I find a problem and solve it only encounter another build issue. Are there more details on how to get this working?
That particular part of README was filled in by @dlech, so may be he can comment on this?
What have you tried so far? Are there error messages you can share?
I've installed the Mentor Graphics CodeSourcery cross compiler. Then I successfully built a hellowrold app and ran it on the ev3. Now I'm trying to build the language bindings. At first I was having trouble getting CMake configured to point to the cross-compiler. Now CMake is running the cross compiler, but it cannot successfully compile code. I see different errors depending on how I configure the cross-compiler: either the compiler itself reports that cannot find header files, or with a different config CMake complains about not being able to compile a test file (without spitting out the exact compiler error).
I built the helloworld app from a native windows/DOS command shell. But my CMake is on my cygwin environment. So maybe there is a problem with running the cross-compiler in cygwin. Or maybe my CMake configuration is not right. I have only ever dabbled in CMake, so I could easily be screwing that part up without knowing any better.
TL;DR: instead of me googling and guessing until it works, I was hoping someone might have a working CMAKE_TOOLCHAIN_FILE or a list of do's and don't's or maybe just an set of pre-built binaries.
What does your CMake toolchain file look like?
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER /cygdrive/c/Users/lee/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/arm-none-linux-gnueabi/bin/gcc.exe)
SET(CMAKE_CXX_COMPILER /cygdrive/c/Users/lee/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/arm-none-linux-gnueabi/bin/g++.exe)
SET(CMAKE_INCLUDE_PATH /cygdrive/c/Users/lee/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/arm-none-linux-gnueabi/libc/usr/include)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /cygdrive/c/Users/lee/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/arm-none-linux-gnueabi)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
@pmclee what version of Windows are you running? If you are running Windows 10, compiling for the EV3 brick is very easy, and I've added instructions on how to do so to this repo's readme.
when i try to Install the ARM compiler by typing sudo apt-get install arm-linux-gnueabi-gcc i receive error: can't find arm-linux-gnueabi-gcc I install gcc-4.7-arm-linux-gnueabi then i need to sudo apt-get install git when i try "CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ cmake .." new error - cmake not intalled so i do "sudo apt-get install cmake" now i try "CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ cmake .." new error -"CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:56 (message): Could not find compiler set in environment variable CC:" now i try "CC=arm-linux-gnueabi-gcc-4.7 CXX=arm-linux-gnueabi-g++ cmake .." error: "Could not find compiler set in environment variable CXX:" now i type: sudo apt-get install g++-4.7-arm-linux-gnueabi now i try "CC=arm-linux-gnueabi-gcc-4.7 CXX=arm-linux-gnueabi-g++-4.7 cmake .." and new error: "CMake Error at CMakeLists.txt:60 (export): export Unknown arguments." What to do? Sorry for my bad english.
It seems like you almost solved this. I think the final error is because the installed cmake is too old. Can you try to apt-get install cmake3 and then
CC=arm-linux-gnueabi-gcc-4.7 CXX=arm-linux-gnueabi-g++-4.7 cmake3 ..
? The package name may be different, but I don't have an Ubuntu system to test this.
thanks. apt-get install cmake3 and CC=arm-linux-gnueabi-gcc-4.7 CXX=arm-linux-gnueabi-g++-4.7 cmake .. resolve problem.
Hi Stephan,
thanks for this great project :)
I ran also into the same Windows 10 cross compiler issues.
An update to Readme would probably help newbies like me :)
Packages to install (arm-linux-gnueabi-gcc, i.e. with gcc at the end is not found/resolved) Thus:
sudo apt-get install gcc-arm-linux-gnueabi sudo apt-get install g++-arm-linux-gnueabi
cmake3 is definitely needed to compile without errors sudo apt-get install cmake3
Compile (note the command is cmake even for cmake3) mkdir build && cd build CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ cmake .. -DEV3DEV_PLATFORM=EV3 make
Thank you and best regards, Robert
Would you care to create a pull request with these changes to README? Thanks!
Hi. I'm a total newbie with all these stuff. I have tried to use cross-compiling on Windows 10 with Windows Subsystem. I'm not sure how exactly i should use the cmake command.
I tried something like that:
..:/ev3/ev3dev-lang-cpp/build$ sudo cmake ../../ev3dev-lang-cpp -DEV3DEV_PLATFORM=EV3
and get the following error:
CMakeError at CMakeLists.txt:1 (add_ev3_executable): Unknown CMake command "add_ev3_executable".
Some infos:
- Debian GNU/Linux installed on the Subsystem
- cmake version 3.7.2
- gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
- g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
added to the CMakeLists.txt: set(CMAKE_CC_COMPILER "arm-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++")
Can you try if this works?
..:/ev3/ev3dev-lang-cpp/build$ cmake .. -DEV3DEV_PLATFORM=EV3
Thanks for the quick response.
This leads to the same error.
CMake Error at CMakeLists.txt:1 (add_ev3_executable): Unknown CMake command "add_ev3_executable".
add_ev3_executable is defined in the main CMakeLists.txt here:
https://github.com/ddemidov/ev3dev-lang-cpp/blob/2e7b4ae0e08511dd8418bedd5636595ea9a68c1d/CMakeLists.txt#L33-L36
so I don't really understand why are you getting the error. I would try again with a fresh clone of the repository and clean build folder.
After i have completely reset the Windows Subsystem, now everything is working. This time I installed ubuntu on the subsystem. But I don't think that was the cause.
Thank you and best regards.