1

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.

Gilgr
  • 73
  • 6
  • Doesn't QT Creator have that option? – ChiefTwoPencils Feb 24 '13 at 08:28
  • What do you mean with "Unix"? Mac OS? Linux? Solaris? FreeBSD? Something else? There's dozens of Unix environments. – Nikos C. Feb 24 '13 at 08:36
  • AFAIK, the closest available solution is remote compilation - when you build the lib in Visual studio, the source files are transferred to a remote UNIX server and compiler there. This is the way how things work in the company I work for. However, it requires writing a plugin for Visual studio. Some other IDE like QtCreator can have this functionality built-in right out of the box. – Dmitry Feb 24 '13 at 08:42
  • I'd see if you can incorporate the VisualAge cross-compiler as an external toolset into dev studio. It would be a pain, but it may be possible. note: its been literally 10 years since I've used VA for AIX dev-work, and for all I know they don't even *do* X-compiling anymore, but if they do, thats an option. – WhozCraig Feb 24 '13 at 08:57

4 Answers4

2

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

1

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

Community
  • 1
  • 1
SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85
0

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

0

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

abcalphabet
  • 1,158
  • 3
  • 16
  • 31