views:

287

answers:

7

I'm taking an Introduction to C++ this semester, so I need to set up development environments in both my Windows and Ubuntu partitions (I switch between them). I was planning to use GCC in both environments for consistency and because I plan to do my serious C++ developing in Linux with GCC.

It appears that installing MSYS and MinGW is the best way to use GCC and replicate my Linux dev environment. However, just setting up MSYS and MinGW in Windows appears to be a long and arduous process, and I'm imagining that I will have limitations or compatibility problems in the future.

  • Do the benefits of setting up a MSYS Linux-like development environment on Windows outweigh the costs?
  • Will I be able to use all the libraries that I could if I were using Visual C++?
+11  A: 

I think you're going about this the wrong way - I would actually suggest you use Visual Studio on the Windows environment, rather than going out of your way to setup GCC. It's a benefit, not a drawback, to run your code on multiple compilers from multiple vendors.

Both GCC and Visual Studio are highly conformant (at least recent versions). You won't have any trouble with standard libraries and going between them, and if you do have trouble, it's probably an issue in your code.

Terry Mahaffey
Hmmm, I hadn't thought about the possible benefits of trying out two compilers. It's like testing Javascript apps on multiple browsers; one might reveal a problem the other one misses. Thanks for the different perspective.
Evan Kroske
Not sure this is as true anymore, C++ standard is a bit better than javascript on different browsers. For reasonably complex projects you are goign to spend a lot of time keeping makefiles and projects in sync and learning where linker flags are in the VS IDE.
Martin Beckett
On th eother hand the VS debugger is excellent !
Martin Beckett
Something like CMake can take care of keeping makefiles/projects in sync
jalf
VS is not really conformant, it compiles a lot of invalid C++ code even with extensions disabled (examples: `struct Test { void Test::A() { } };`, `struct Test { template <class T> void a() { } };`, `vector<vector<int>>`, `enum` are automatically converted to `int` when calling a specialized templated function). Don't get me wrong, I **love** VS, I just think it's annoying that when I commit the build fails and people get mad at me. (PS: no warnings are issued for any of the above; in GCC they are all errors)
Andreas Bonini
@Andreas You're right on the first count (with the extra qualification to Test::), but your second and third examples are perfectly legal code which compile in both VC and GCC (the "maximal munch" problem with >> was a standard defect, the solution to which has been implemented by all major compilers for years). And, um, enums are suppose to convert to int on demand. I don't quite understand what you are getting at here - can you be specific?
Terry Mahaffey
@Terry: I wrote the second code for #2 (I misremembered); what I meant to write is: `struct Test { template<typename T> static T a() { return T(); } template<> static int a() { return 5; } }; int main() { Test t; t.a<int>(); }`. This (template specialization inside class definition) will compile with VS and not with GCC.
Andreas Bonini
@Terry: for #3, it doesn't matter if it's an error in the standard or not.. If it compiles on VS and not on GCC then it's a problem
Andreas Bonini
@Terry: for #4, this is a test case that will compile without warnings on VS but fail on GCC: `namespace Test { enum { Testing }; } int main() { boost::format("%s") % Test::Testing; }`
Andreas Bonini
+1  A: 

If you stick with the automated installer, MinGW installation is not painful at all. Unfortunately, that currently gives you GCC 3.4.5, rather than the newer 4.4.0 release that they also provide sans installer.

In reality, for course work, 3.4.5 will be just fine, I imagine.

Drew Hall
+3  A: 

I've always installed cygwin on Windows. To me, Windows is completely unusable without it. I've never really run into problems with DLLs mentioned above. However, I've also rarely used the GCC compiler, so I don't know how it compares to Visual Studio for general programming. For anything with a Windows GUI or Dot Net based, I would definitely stick with Visual Studio.

Greg Charles
+1  A: 

Use gcc on Ubuntu and Visual Studio on Windows to get exposure to both. This is an intro course so Windows, Linux, Visual Studio, gcc are just the tools you need to master C++ and data structures. Mastering the tools will come over time and they will change.

fupsduck
+1  A: 

I personally develop for windows using a pure Linux environment using mingw-gcc on Linux to cross-compile for windows. I put a tutorial on how to set it up for OpenSSL/Qt4 @ http://www.limitlessfx.com

OneOfOne
A: 

Do you do this to get .exes or just to be able to work on both OSes?

If you feel more comfortable with GCC than VC, setting up Mingw/Cygwin is possible but doesn't give you any new functionality (beside .exes). Instead, I suggest you turn one of your partitions into a virtual machine - this way you can have both OSes open at once! (My personal choice is Windows inside Linux, YMMV.)

The benefit of developing on Linux is ready availability of tons of development tools and libraries. Also, big builds are noticably faster.

Beni Cherniavsky-Paskin
A: 

Since you said "I plan to do my serious C++ developing in Linux with GCC", VC++ may not be what you really want. Many libraries just don't compile well in VC++. Try some yourself. Instead, consider running Linux on Windows. There are several ways to do this:

  1. Use PuTTY to connect to a Linux machine, and use Xming to see the UI windows. I would only do this over a LAN.
  2. Consider coLinux. You can run Linux under Windows and just shut-off Linux when you are done.
  3. Consider other virtualization options like VMWare to run Linux. Pretty much the same as coLinux, but it might be easier to setup.

You may even want to install Linux directly on your machine. You can always use tools like Wine or VMWare to run Windows if you need it.

User1