Costs and benefits of Linux-like Windows development environment
Asked Answered
T

7

6

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++?
Tontine answered 7/1, 2010 at 21:59 Comment(2)
The "costs" depend on what your course contains of - if its just using standard libraries there will be no real problem.Jarrett
cygwin's installer is hardly straightforward, cygwin has traditionally been rather intrusive (until the recent 1.7 release, multiple copies of the DLL weren't allowed to co-exist peacefully), and it's hard to uninstall. I don't recall installing MinGW and MSYS to be that long and arduous of a process, and it has the benefit that it will compile native Win32 binaries.Rochkind
R
11

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.

Recommendation answered 7/1, 2010 at 21:59 Comment(8)
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.Tontine
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.Glean
Something like CMake can take care of keeping makefiles/projects in syncDialyser
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)Ribal
@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?Recommendation
@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.Ribal
@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 problemRibal
@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; }Ribal
C
3

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.

Currycomb answered 7/1, 2010 at 21:59 Comment(0)
M
1

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.

Mccombs answered 7/1, 2010 at 21:59 Comment(0)
C
1

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.

Candescent answered 7/1, 2010 at 21:59 Comment(0)
V
0

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.

Vociferation answered 7/1, 2010 at 21:59 Comment(0)
G
0

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.

Guillen answered 7/1, 2010 at 21:59 Comment(0)
K
0

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

Kitchen answered 7/1, 2010 at 21:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.