views:

282

answers:

4

At my work all of the project data resides on an NFS that is accessible from both Linux and Windows machines (using Samba). All of the work is done on Linux, but I'm toying with the idea of compiling some of tools for Windows so that I can debug with Visual Studio.

I already have a nice makefile that can build the code for both 32-bit or 64-bit Linux using different targets. Assuming I have windows versions of all the external libraries somewhere on the NFS, and assuming the code is clean enough to compile under Windows, is it possible to compile and link my program for Windows using the existing makefile, on Linux? Ideally I'd like to call the makefile once and have it build all three of 32-bit Linux, 64-bit Linux and Windows.

An added plus would be the option to compile it with any Visual Studio metadata to make it easy to debug.

+1  A: 

What you're asking for is called a "cross-compiler".

ChrisW
+1  A: 

Yes, you can achieve that with MinGW for example. http://www.mingw.org/wiki/MinGW

However, you will probably have to adapt one or two options in your makefile.

Sobe
MinGW runs on Windows, not Linux. But it will at least build a native Windows application using the GNU tools familiar to Linux users. Beware however that MinGW uses Microsoft's MSVCRT.DLL C runtime rather than GNU libc.
Clifford
MinGW runs on Linux too.
Ben Alpert
MinGW runs on Linux as well, and it's what's normally used for Linux->Windows cross-compilation.
Lukáš Lalinský
@Clifford - http://silmor.de/39 for example says how to build MinGW to run on Linux.
ChrisW
Hum... Sorry but I got it installed on Linux (Xubuntu, but it seems it comes from Debian => packages "mingw32", "mingw32-binutils" and "mingw32-runtime" - These packages contain "C and C++ cross compilers").I used it once or twice to compile things that didn't wanted to drectly on Windows.
Sobe
I stand corrected then. It still does not support the OP's requirement to "debug with Visual Studio" however.
Clifford
+1  A: 

There are a number of possibilities I can think of:

  • You might try running Visual Studio under Wine. If Visual Studio does not run, you may still be able to run the command-line tools.

  • Run a full installation of Windows in a Virtual Machine. I have done this with Linux on Windows, but not the other way around, but I am certain that it is possible.

  • Use VNC to access a separate Windows PC from the Linux PC

  • Use a cross-build of GCC instead of Visual Studio

Clifford
Why listing the best option as the last one?
gimpf
@gimpf: Listed as they ocurred, and 'best option' is a matter of opinion. The OP wanted to use the Visual Studio debugger, and the last option does not support that aim, so I would say that it was not the bast solution in this case.
Clifford
+1  A: 

you need cross compilation package,also you can wine lib

SomeUser