Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a Visual C++ Project for Linux?

What's the best and easiest way to build (for Linux) a C++ application which was written in Visual Studio? The code itself is ready - I used only cross-platform libs.

Is it possible to prepare everything under Windows in Visual Studio and then build it with a CLI tool under Linux? Are there any docs describing this?

EDIT: Some more information:

  • Libs used: stl, wxwidgets, boost, asio, cryptlib.

  • Very little Linux know-how.

EDIT#2: I chose the following solution: Make new project with kdevelop and compile everything there.

like image 202
mspoerr Avatar asked Apr 29 '09 15:04

mspoerr


People also ask

Can Visual C++ 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.

Can Visual Studio target Linux?

Visual Studio does not have a requirement for a specific distribution of Linux; use any you would like to. That can be on a physical machine, in a VM, the cloud, or even running on Windows Subsystem for Linux. The tools Visual Studio requires to be present on the Linux machine are: C++ compilers, GDB, ssh, and zip.


2 Answers

We're using CMake for Linux projects. CMake can generate KDevelop and Visual Studio project files, so you can just create your CMake file as the origin of platform-specific IDE files. The KDevelop generator is fine, so you can edit and compile in KDevelop (which will in turn call Make).

On the other hand, if you have nothing fancy, you can use CMake or just Make to build the thing on Linux, if you want to stay with your solution file (which is what I'm currently doing for a library with test applications). This approach gets complicated when your build process is more than just "throw these files at the compiler and let's see what it does", so the CMake solution is in my opinion a good thing for cross-platform development.

like image 133
OregonGhost Avatar answered Sep 24 '22 08:09

OregonGhost


8 years later ...

I stumbled across this question today and thought you might like to take a look at Visual C++ for Linux.

Released in March 2016, VC++ for Linux allows you to create a project in VC++, and then build it in a Linux machine/VM using native Linux tools. What's more, you can also debug your app from within VS since the Linux tools allow the VS debugger to drive GDB in your Linux machine/VM via SSH!!

Looks like this is almost exactly what @mspoerr was asking for :)

like image 37
Rich Turner Avatar answered Sep 22 '22 08:09

Rich Turner