Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-compiling not working on Windows #20

Open
pmclee opened this issue Mar 6, 2017 · 16 comments
Open

cross-compiling not working on Windows #20

pmclee opened this issue Mar 6, 2017 · 16 comments

Comments

@pmclee
Copy link

pmclee commented Mar 6, 2017

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?

@ddemidov
Copy link
Owner

ddemidov commented Mar 6, 2017

That particular part of README was filled in by @dlech, so may be he can comment on this?

@dlech
Copy link
Contributor

dlech commented Mar 6, 2017

What have you tried so far? Are there error messages you can share?

@pmclee
Copy link
Author

pmclee commented Mar 6, 2017

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.

@dlech
Copy link
Contributor

dlech commented Mar 6, 2017

What does your CMake toolchain file look like?

@pmclee
Copy link
Author

pmclee commented Mar 7, 2017

# 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)

@nesteruk
Copy link
Contributor

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

@stephanthe
Copy link

stephanthe commented Jul 6, 2017

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.

@ddemidov
Copy link
Owner

ddemidov commented Jul 6, 2017

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.

@stephanthe
Copy link

thanks. apt-get install cmake3 and CC=arm-linux-gnueabi-gcc-4.7 CXX=arm-linux-gnueabi-g++-4.7 cmake .. resolve problem.

@robert4os
Copy link

robert4os commented Sep 7, 2017

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

@ddemidov
Copy link
Owner

ddemidov commented Sep 7, 2017

Would you care to create a pull request with these changes to README? Thanks!

@Jawaisch
Copy link

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++")

@ddemidov
Copy link
Owner

Can you try if this works?

..:/ev3/ev3dev-lang-cpp/build$ cmake .. -DEV3DEV_PLATFORM=EV3

@Jawaisch
Copy link

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

@ddemidov
Copy link
Owner

add_ev3_executable is defined in the main CMakeLists.txt here:

function(add_ev3_executable target sources)
add_executable(${target} ${sources})
target_link_libraries(${target} ev3dev)
endfunction()

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.

@Jawaisch
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants