Cross compiling question in CLion Win to VM Linux

已回答

Good day,

I just installed CLion as I need to do some work on a pre-made C++ program using makefiles. I really like JetBrains products and would like to investigate the CLion. My question is related to cross-compiling from Windows to Linux - how would be the most efficient way?

I have the C++ files and a working CMakeTexts for using in Ubuntu. Compiling it in Ubuntu with cmake and make is not a problem and the program works as expected but I need to investigate the program and do some changes while being relatively new to C++.

I have set up a virtual machine running Ubuntu and created a shared folder between my Windows machine and the guest machine. The guest has access to the shared folder and all the rights. I thought of having the whole program in that shared folder and then compile it into there with CLion.

I have set up Cygwin and compilation goes without issues using the same compiler as in Ubuntu terminal. When running the compiled binary in Linux, I get a message "cannot execute binary file: Exec format error". The file type in Ubuntu is recognized as "DOS/Windows executable (application/x-ms-dos-executable)" so no wonder it doesnt run.

Does anybody have a good idea how to compile my application straight from the IDE with Clion, targeting a VM running Ubuntu?

0

Hello! 

For your scenario Microsoft Subsystem for Linux (WSL) should be suitable. It helps when you need to use Linux toolchain to build a project on your Windows machine.

Please read a detailed blog post about WSL support in CLion: https://blog.jetbrains.com/clion/2018/01/clion-and-linux-toolchain-on-windows-are-now-friends/. Also here is a web help article about the configuration details: https://www.jetbrains.com/help/clion/how-to-use-wsl-development-environment-in-clion.html.

0
Avatar
Permanently deleted user

I will give it a try and post in here if I encounter some issues - but I understand that I can do the development only on the sub system with WSL. I cannot develop directly for the virtual machine, right? I mean that I would like to execute my code in there, or on another physical Linux machine.

Do you have any ideas why the Cygwin way does not work?

0

> but I understand that I can do the development only on the sub system with WSL. I cannot develop directly for the virtual machine, right?

You will be able to develop on WSL Ubuntu/OpenSUSE/SLES. You will be able to transfer the resulted executable to other Linux machines.

> Do you have any ideas why the Cygwin way does not work?

CLion doesn't have a remote project support yet. Please comment or upvote https://youtrack.jetbrains.com/issue/CPP-744 in order to get updates.

 

0

请先登录再写评论。