简体   繁体   中英

Compiling a project for both Windows and UNIX machines from Visual Studio 2012

I'm trying to find a quick way to compile a C++ project for Windows and UNIX (AIX) environments, using Visual Studio 2012 (+anything else I might need).

I'm mainly interested in the compilation part, not the changes needed in the code itself. If Visual Studio has no support, is Cygwin a good way to go? Is there anything better?

Thanks!

*Edit: The project is intended to be a dll (and so) - if this changes anything.

Simple answer: You can't.

Keep your UNIX and Windows development environments separate, and share code through some software management repository such as git or Perforce. (I recommend the latter.)

VS can't produce Unix binaries.

As part of the VS build you can run a script that will invoke, for example, a Unix compilation via some cross-compiler.

Edit : Per NikosC. comment Cygwin doesn't produce Unix executables. Maybe this thread can help: How do I cross-compile C code on Windows for a binary to also be run on Unix (Solaris/HPUX/Linux)?

You can try the same netbeans remote build plugin and debugging. Below is the link for the same, i am using it to build on linux and solaris. For windows you can run sshserver

https://netbeans.org/kb/docs/cnd/remotedev-tutorial.html I hope this will help

For linux this has become possible as of Visual Studio 2017! You do need to have access to a linux machine though, where the actual build for linux will be performed.

Visual Studio 2017 introduces the C/C++ Linux Development workload. To install it, start the Visual Studio installer and choose to either install or modify an existing installation. Scroll to the bottom. Under the section “Other Toolsets” you will find Linux Development with C++.

You can use any Linux distribution that has SSH, gdbserver, and a compiler installed. In your Linux environment, this is as easy as:

 sudo apt install -y build-essential gdbserver 

To create a new Linux Console Application in Visual Studio, select that project type under New Project > Visual C++ > Cross Platform > Linux.

For more detailed information check out this blog post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM