views:

157

answers:

6

Is there any Visual C++ compiler for linux supporting most of VS Visual C++?

If there is no such what is best alternative for porting\adapting your visual C++ code to?

+1  A: 

When I am porting my Windows code to Linux, I usually use Eclipse in Windows along with minGW.

linuxuser27
MinGW is for running code dependent on Linux standard libraries in Windows; it doesn't help you run managed code in Linux
Michael Mrozek
Oh, I did not realize he was talking about CLI. Should have looked at the tags.
linuxuser27
+1  A: 

I use NetBeans with TDM-GCC. Unfortunately I have not been able to get gdb to work under windows.

Jay
Try cygwin - You'll probably have better luck with that if you want `gdb` to work. It'll give you `gcc`, `gdb`, `make`, and whatever else you want (just make sure to select the right packages)
mathepic
Thanks Matt. I'll try cygwin
Jay
+2  A: 

If you mean a compiler that supports most of the VS extensions/standards non-compliance you're out of luck. If you mean an environment to compile/port to Linux, I would just use g++ and get yourself an editor such as Emacs. I've also heard good things about Code::blocks.

Mark B
+3  A: 

I don't think there's a compiler for Managed C++ or C++/CLI other than for Windows. The Mono project (.NET for Linux) has a C# compiler, although I don't know how up to date that is.

Anyway, I thought the whole idea about .NET was that it is a platform in itself. Can't you just run your Windows executables on Mono?

sbi
If I'm not mistaken, the Mono project finished .NET 4.0 before Microsoft did. Hah.
Chiggins
+4  A: 

Mono supports running CIL-only (meaning no mixed-mode assemblies) C++/CLI assemblies, but there's no C++/CLI or Managed C++ compiler on Linux.

You can read information about this in the Mono project page: http://www.mono-project.com/CPlusPlus

Matias Valdenegro
+3  A: 

Visual C++ refers to an Integrated Development Environment and C++ Compiler. It is strictly Windows only * implementation* for all practical intents and purposes.

C++ is a language. Linux has several compilers for C++. If you use non-portable extensions, such as #pragma once instead of include guards, using the DLL import/export stuff, or the Windows APIs type system, then your code will be less portable between implementations. Much of this can be controlled with judicious use of the pre processor and some common sense.

The best way is to write portable code and libraries in the first place. It is not as hard as it sounds.

Now for this comment: I will apologise for sounding offensive, but if you can't tell the difference between "C++" and "Visual C++", please learn such elements of the English language (and C++). It will help you in the long run, programming wise.

Compilers for Linux -> GNU C/C++ (GCC/G++). See also Intels compiler.

IDEs for Linux -> generally run on Windows too, check wikipedia.

TerryP
AFAIK, modern GNU compiler versions have some way of supporting part of MS's declspec stuff, a la exporting from a DLL.
TerryP