Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile in Visual Studio 2010 for Linux

Is it possible to develop C/C++ on Windows using Visual Studio 2010 (not necessarily the MSVC Compiler) and get a binary that I can upload to a linux machine (and run it)?

On possibility I checked was to use MinGW or something similar to get windows binaries doing the same thing that linux binaries would do but I had problems to get all win-ports for all needed libraries (posix).

EDIT: I do not want to let the windows binary run on linux. I need a native linux binary as a result.

like image 973
schoetbi Avatar asked Feb 07 '12 05:02

schoetbi


People also ask

Can Visual Studio compile for Linux?

Visual Studio 2015 has brought with itself a cross-platform support for native C++ projects. In this context cross-platform means Windows, Android and iOS. New Visual Studio now officially supports CLang and GCC tool-chains along with its own compiler. However it doesn't support cross-compilation to Linux.

How do I compile code in Visual Studio terminal?

Open your C++ code file in Text Editor, then use shortcut Ctrl+Alt+N , or press F1 and then select/type Run Code , or right click the Text Editor and then click Run Code in context menu, the code will be compiled and run, and the output will be shown in the Output Window.

Can Visual C++ run on Linux?

It's found at the top of the table of contents on this page. You can use the Visual Studio IDE on Windows to create, edit, and debug C++ projects that execute on a remote Linux system, virtual machine, or the Windows Subsystem for Linux.


1 Answers

Thanks to all of you! My solution is summarized:

  1. Platform-independent code is developed using Visual Studio
  2. Final Build (for Linux) is performed using a Virtual Box running Debian or RHEL
  3. IDE within the Virtual Box is Eclipse with the CDT plugin
  4. Use CMake To generate the project files for both Visual Studio and Eclipse CMake
like image 57
schoetbi Avatar answered Sep 21 '22 23:09

schoetbi