View Full Version : Best C++ Compiler
Computerrock
11-26-2008, 06:53 PM
What opensource compiler is powerful, easy to use, and works well with C++ engines?
Reedbeta
11-26-2008, 11:47 PM
Windows flavor: MinGW (http://www.mingw.org/).
Linux/Mac flavor: gcc (http://gcc.gnu.org).
.oisyn
11-27-2008, 04:51 AM
Do you really mean opensource or just free? Because the express edition of Visual C++ is free and pretty good too. Although it doesn't optimize as heavily as the (non-free) professional version if I'm not mistaken.
martinsm
11-27-2008, 12:17 PM
hm.. Really? I all the time though that compiler (cl.exe/link.exe and their functionality) from express VS versions does not differ from professional version. Only some libraries or IDE features are missing.
.oisyn
11-27-2008, 12:19 PM
That might very well be. I only know that in the past (VS 2003 and before) the Professional edition came with the optimizing compiler while the standard edition didn't, and I also thought that was true for the Express edition, but I'm not certain about that.
.edit: it seems that you are right. VC++ Express is lacking 64 bit support (but you can get the command line compiler with the Windows SDK), a resource editor, and ATL, MFC or OpenMP support. http://en.wikipedia.org/wiki/Visual_C%2B%2B_Express_Edition#Visual_C.2B.2B_Expr ess
JarkkoL
11-27-2008, 02:42 PM
Only problem with Express edition for me is the lack of plugins, so you can't have Visual Assist nor Perforce integration. Otherwise it's a good compiler + IDE.
.oisyn
11-27-2008, 04:47 PM
Yeah no Visual Assist is a bummer, but perforce integration sucks anyway, especially if the server is not located in the same building let alone the same country (which has more to do with VS' implementation of source control handling - it takes a LOT of roundtrips to get information about all the files). I've created a set of macro's that allows you to add, edit, revert and delete files using a toolbar button (for the active open document) or the solution explorer context menu. It also has the option to edit all unsaved files at once, and it can remap file paths based on a config file if you happen to use NTFS junctions (or any other reason for discrepancies between file paths and the perforce client spec). I bet these macros work in Express as well ;)
leoptimus
11-27-2008, 05:05 PM
What opensource compiler is powerful, easy to use, and works well with C++ engines?
Compiler:
If you're refering to open source, the only choise is GCC( gcc for linux, also known as MingW fow windows). Yes, there are other opensource compilers too but they're all useless.
If you're looking for free compilers, they're only two: GCC and Microsfot c++ Compiler version 8-9 express. But GCC is much better because is more standard and its usability is the same for PC, Consoles (Wii, PS2,PSP,PS3,DS, Dreamcast, Nokia, Palm, Iphone), Mac, Solaris etc. Microsoft Compilers are only for windows.
GCC manages the C++ language compilation following ansi standards, while Microsoft doesn't. Some times the c++ code made for Microsoft compilers are totally incompatible for other compilers (gcc, intel) . Microsoft promotes to break standards and encourages totally dependency to its unique plattform (windows).
Also, GCC supports more languages than c++, like D, Pascal, ADA, Java,ObjetiveC, Fotran etc. Microsoft only C++, nevertheless you want to use .NET framework for programming in other languages like C#.
IDE
Compilers , Easy to use? never, because tipically compilers aren't easy to use. All of them need to be used in similar ways: command line primitives, and they aren't obvious.
But may you're refering to IDEs for programming in c++. There are four c++:
Visual Studio C++ IDE 2005 - 2008: The most used, the most popular. It isn't easy to use at all. Complete features. Robust interface for debugging code. Responsible and accurate Intellisense. Configuring projects on it is a little complicated. A little bloat and consumes machine resources. MultiCompiler??
Code::Blocks: Open source and free. The easiest to use IDE. Crossplatform. Lightweight. Has intellisense, but not always accurate. Its editor is similar to Visual Studio but I found it more easier for navigating through the code. It allows to configurate projects very easy. Productive. Multi-Compiler : VC, GCC, Intel.
Netbeans.Open source and free. Crossplatform. Similar to Visual Studio IDE, but more heavyweight and bloater. Works for c++ through a plugin (that's bad). Consumes a lot of machine resources. ITs intellisense is not always accurated. Debugging code on it is not as pleasurable as on Visual Studio or CodeBlocks. Not so productive. Multi-Compiler : VC, GCC, Intel. works with many languages: java, c++, php etc.
Eclipse. Open source and free. Crossplatform. Similar to Visual Studio IDE, but more heavyweight and bloater. Works for c++ through a plugin (that's bad). Consumes a lot of machine resources. ITs intellisense is not always accurated. Debugging code on it is a totally hell. Not so productive. Hard to use. Multi-Compiler : VC, GCC, Intel. works with many languages: java, c++, php etc.
For c++ engines:
If you have to use DirectX, the only choice is Microsoft Visual Studio C++ because DirectX is microsoft stuff. Otherwise I highly recommend Code::Blocks for everything, the most productive IDE. And also I highly recommend GCC above the 4.1 version, because is a very efficient compiler and produces faster executables, and also has more hardware profiles than Microsoft (support for Core 2 Duo).
But if you want the most efficient applications for c++, you should work with Intel Compiler, which isn't free. However, GCC 4X produces applications with a closer performance to the ones produced by Intel compiler.
Reedbeta
11-27-2008, 07:13 PM
I've created a set of macro's that allows you to add, edit, revert and delete files using a toolbar button (for the active open document) or the solution explorer context menu.
Cool. I just have Ctrl+E bound as an "external tool" that `p4 edit`s the active file and everything else I do through p4v (Perforce GUI).
Sol_HSA
11-28-2008, 02:59 AM
Compiler:
If you're refering to open source, the only choise is GCC( gcc for linux, also known as MingW fow windows). Yes, there are other opensource compilers too but they're all useless.
If for some mysterious reason you need to make a 16-bit DOS application, openwatcom can't be beat. =)
.oisyn
11-28-2008, 03:40 AM
Compiler:
If you're looking for free compilers, they're only two: GCC and Microsfot c++ Compiler version 8-9 express. But GCC is much better because is more standard and its usability is the same for PC, Consoles (Wii, PS2,PSP,PS3,DS, Dreamcast, Nokia, Palm, Iphone), Mac, Solaris etc. Microsoft Compilers are only for windows.
And Xbox. And since this is a gamedevelopment forum Windows and Xbox might just very well be the only things you need ;)
GCC manages the C++ language compilation following ansi standards, while Microsoft doesn't.
I'm sorry but this is just plain bullshit from the top shelf. I think your arguments come from the pre 2003 age. Since 2003 there were a LOT of improvements to ISO C++ compliancy in VC++. There are a few non-compliant issues, but gcc has those as well. There is only one group of true ISO C++ compliant compilers, and those are the ones based on the EDG C++ compiler front-end (such as Intel C++, Comeau, Borland C++ Builder X, ...).
As for the rest of your post, stop spreading your FUD.
anubis
11-28-2008, 12:20 PM
I'm sorry but this is just plain bullshit from the top shelf. I think your arguments come from the pre 2003 age. Since 2003 there were a LOT of improvements to ISO C++ compliance in VC++. There are a few non-compliant issues, but gcc has those as well.
I would prefer gcc for philosophical reasons but it's true that VS had some serious improvements over the last years. If you enable ISO C++ mode in VC++ it's a lot more picky than gcc.
Anyone who still remebers the for (int i=0; ...; ...) bug in VC 6 is bound to hate it. I currently port a lot of code between Linux and Windows tough and need to keep it working on both platforms. I have to say that the issue is hardly there anymore. Most of the stuff I am really concerned with is missing POSIX stuff in VS but that's a thing they never promised in the first place, so I can't complain about that.
I might add that in my experience VC++ is no match for gcc 4.1 upwards regarding performance. That is a highly opinionated statement though and I don't have hard data to back it up.
anubis
11-28-2008, 12:26 PM
Also gcc allows quite a bit of non standard code that is used in the linux kernel :)
Reedbeta
11-28-2008, 02:53 PM
I might add that in my experience VC++ is no match for gcc 4.1 upwards regarding performance.
Do you mean in terms of compilation performance or performance of the generated code? On larger projects, or smallish ones?
I've seen VC++'s optimizer to be generally superior to that of gcc. As for the compilation performance, it's hard to say, but I feel like VC++ might be slightly better at incremental compilation, i.e. recompiling only things that have been affected by a code change. Like you, though, I don't have any hard data on this.
.oisyn
11-28-2008, 03:50 PM
I currently port a lot of code between Linux and Windows tough and need to keep it working on both platforms. I have to say that the issue is hardly there anymore.
I agree. I use both compilers, MSVC++ for Windows and 360, GCC for PS3, and I have yet to write a piece of code that doesn't work out of the box on any one of the compilers. I also think both compilers somewhat grew to eachother with respect of non-standard stuff. Think about VC++'s __declspec and gcc's __attribute__. They pretty much buth support the same type of stuff like alignment, and you can put it in the same position in a declaration, which makes it easy to use a single cross-platform macro. IIRC, in the early days it wasn't that easy because the __attribute__ had to be put in a different spot than the __declspec, forcing the coder to use two macros.
I might add that in my experience VC++ is no match for gcc 4.1 upwards regarding performance.
I don't really have an opinion as I use the compilers on different platforms, but I've seen both lots of impressive stuff and stuff that makes you think "OMG WHY?!" with both compilers.
leoptimus
11-28-2008, 04:47 PM
Do you mean in terms of compilation performance or performance of the generated code? On larger projects, or smallish ones?
About generated code, GCC 4.2 (Mingw) and Microsoft C++ compiler, both always produce efficient and optimized applications. Some programs run faster when they're generated with Mingw, and other could run faster if they're compiled with Microsoft C++ compiler. There are a lot of aspects that makes an application more hardware efficient. F.E: the STL library from GCC it's more efficent that the one present in Microsoft Visual C++ (in my personal benchmarks), but SIMD code could be a little faster if it is generated on Visual Studio.
The story was different in times of GCC prior to 4x version (2.x to 3.3); in that time GCC couldn't beat Microsoft in generated code.
About compilation time, VC++ has been always the fastest. But the difference is not noticeable comparing with gcc, even for big projects (with more than 1000 source files the difference is only about minutes (3-5)).
The choice is that if you want cross-platform, you should use GCC for everything. The fact is that is really hard to make cross-platform code with VC++. You must decide between Windows and Open-Standards.
But if the Windows world is what you think that only matters, go straight foward with Microsoft Visual Studio.
anubis
11-28-2008, 05:06 PM
I just really really hate at&t assembly syntax :) So on that I'd pick VC's inline assembly any day. Allthough I seldomly use it anymore...
Do you mean in terms of compilation performance or performance of the generated code?
Execution performance. What I base this on is ray tracing and modelling algorithms I have implemented. I don't know if gcc is able to optimize certain areas especially well. As I said... I'm not claiming truth on this :)
SamuraiCrow
11-28-2008, 05:44 PM
Actually, LLVM-GCC is a special version of GCC that will work on most platforms once compiled. It differs from standard GCC in that it uses the Low-Level Virtual Machine (http://www.llvm.org/) which generates code more quickly than standard GCC and debatably can make cleaner code than standard GCC also.
-edit-
As of version 2.4 of LLVM, 64-bit Windows is still unsupported. That is slated to come in version 2.5.
SmokingRope
11-28-2008, 07:21 PM
Compiler:
If you have to use DirectX, the only choice is Microsoft Visual Studio C++ because DirectX is microsoft stuff.
Is there any validity to this statement? I have not tried MinGW (for example) and DirectX but would be rather surprised if it is not possible.
Reedbeta
11-28-2008, 09:00 PM
The fact is that is really hard to make cross-platform code with VC++. You must decide between Windows and Open-Standards.
Actually, I've developed a couple projects (luabridge (http://luabridge.sourceforge.net) as well as my raytracer, "stanley"), that compile in both MSVC and gcc, and I didn't have much trouble at all getting both builds to compile warning free from one code base.
anubis
11-29-2008, 12:50 AM
Is there any validity to this statement? I have not tried MinGW (for example) and DirectX but would be rather surprised if it is not possible.
It should work with other compilers. There is no special DirectX integration into VC. I have used it on Borland allthough that was years ago, I would be surprised if any of this has really changed.
SmokingRope
11-29-2008, 03:36 AM
From experience Eclipse and MinGW is great for cross-platform OpenGL development. Having the same IDE and compiler, on windows and linux, side-by-side, is a time-saver. When it was time to release, i was compiling for macintosh, even though during development i never touched one.
Project configuration has a fairly steep learning curve. I went with CMake and build targets (http://www.cmake.org/Wiki/CMake:Eclipse_UNIX_Tutorial), although IIRC you can use makefiles right out of the box. The debugger was reasonably powerful and could do memory inspection, conditional breakpoints and code stepping.
Despite the synposis by leoptimus once you have it configured you can get a lot done.
.oisyn
11-29-2008, 06:00 AM
The choice is that if you want cross-platform, you should use GCC for everything. The fact is that is really hard to make cross-platform code with VC++. You must decide between Windows and Open-Standards.
Again total and utter bullshit. That is not a fact at all, it's your opinion, and your opinion is wrong. If you write standard C++, it will compile with almost every compilerm including VC++ (7.1, which was released 5 years ago (!!), and up). Now if you're using compiler extensions, of course you have to make sure that you guard these with #ifs or convenient macros, but that is regardless whether you use VC++ or gcc. And of course, if you're using a single compiler on different platforms, writing cross-platform code is easier, but then you're not using open standards anyway but GCC extensions.
So the actual fact is, if you're using only gcc you don't have to care about standards. If you use multiple compilers (such as gcc and VC++), then you have to write standard code or at least make sure your non-standard code works with both compilers. Period.
Look, obviously you have your opinions about Microsoft and Windows. And while I somewhat question their validity, you are entitled to them. However, I think it's clouding your judgement. You think your arguments are based on facts, but they aren't. They're based on ancient history and FUD.
TheNut
11-29-2008, 08:08 AM
I'm with .oisyn. Write proper c++ code and portability pretty much takes care of itself. There are minute differences in libraries, but with good design you can abstract all of that into high level APIs. My engine runs both on Windows and Linux and I use both Visual Studio and vi/GCC and the two work absolutely well with each other. I will add this however, MinGW and Visual Studio do not always work well together. If you plan on using a lot of open-source libraries, you might be better off with MinGW and MSYS because they compile these libraries right off the cuff. And that's mostly because these projects are likely to support makefiles before they do Visual Studio solutions. You can still use Visual Studio to compile them, but you will likely run into nonexistent to poorly written cross-platform code.
JarkkoL
11-29-2008, 08:39 AM
For any open source library worth integrating to your project, I would say that they always compile with VC++.
Computerrock
11-29-2008, 11:51 AM
How do you integrate two different engines into one project without compatability issues?
Reedbeta
11-29-2008, 12:00 PM
Most open-source libraries I've used either come with VC++ project files or someone out on the Internet has already made project files available for them.
How do you integrate two different engines into one project without compatability issues?
Back up. What are you trying to accomplish? Why do you think you need two different engines in one project?
Computerrock
11-29-2008, 12:17 PM
I don't need two engines however, I would like to try to make my project a little more versatile. I'm simply creating a 3D FPS, for my entertainment. Nothing big
leoptimus
11-29-2008, 01:40 PM
I don't need two engines however, I would like to try to make my project a little more versatile. I'm simply creating a 3D FPS, for my entertainment. Nothing big
Simply use Code::Blocks + Mingw + Irrlicht:
http://www.codeblocks.org/downloads/5
Only you have to download 20 mb, 1 minute instalation and you will get it running with all toys.
Quote:
Is there any validity to this statement? I have not tried MinGW (for example) and DirectX but would be rather surprised if it is not possible.
It should work with other compilers. There is no special DirectX integration into VC. I have used it on Borland allthough that was years ago, I would be surprised if any of this has really changed.
Since version 9 DirectX no longer allows to be used with other compilers appart from Microsoft C++. Why? because Microsoft don't want to release its DX static libraries with binary compatiliby to Mingw. There aren't any *.a files of DX9 that actually work.
Why Microsoft don't want to support other party technology ? why DX are incompatible with gcc? Because Microsoft hate Open Source. Yes, that's the big reason. That's why .NET couldn't run on Linux or Mac, because they don't want that the open source guys touch their precious things. The only thing that Microsoft wants is the totally dependency from Windows for everyone. That's why there is Mono, for mimic the .NET functionality.
If you want DirectX benefits, you have to get married with Microsoft per secula. But if you suddenly use open source tools like MingW, you will get excluded from Microsoft World instantanelly.
JarkkoL
11-30-2008, 12:17 PM
Since version 9 DirectX no longer allows to be used with other compilers appart from Microsoft C++. Why? because Microsoft don't want to release its DX static libraries with binary compatiliby to Mingw. There aren't any *.a files of DX9 that actually work.
You don't have to link to DX static libraries in order to use it.
leoptimus
11-30-2008, 01:01 PM
So how do I import DX dll symbols?? since those DLL don't contain plain C functions. DLLtool.exe doesn't work well with those DX dll files because it cannot import C++ reference symbols. That's why the *.LIB files are needed.
Indeed, I did be able to adapt some DLL to MingW whose have been released for VC initially, like the Nvidia Cg libraries. Since their interface is C compatible, I could import their symbols very easy with DLLtool.exe utility.
Are you suggesting that it must be done via COM primitives? if so it becomes too complicated, and that's why DX only can be used with Visual Studio.
JarkkoL
11-30-2008, 01:27 PM
You only need to get access to Direct3DCreate9 function of d3d9.dll, which is plain C function. It's actually better to not use import libraries because then you can fail properly if DX isn't installed.
Reedbeta
11-30-2008, 04:28 PM
Isn't it the case that the C++ ABI is not exactly the same between gcc and VC++? If so, does that lead to potential calling convention issues when trying to call DirectX functions from a gcc-compiled application?
If not, I don't think there are any barriers to using DirectX with gcc, as you get all the procedure addresses through vtables anyway. In other words, differences in C++ name mangling between the compilers are not an issue.
JarkkoL
12-01-2008, 12:18 AM
I couldn't tell since I haven't used DirectX with GCC. All I'm saying is that you don't need the static libs in order to use DX but there may as well be other reasons that it wouldn't work.
.oisyn
12-01-2008, 03:52 AM
bla bla bla
Talking to a brick wall is more useful than trying to convince you that your shitty arguments are in fact quite shitty. And since you're obviously not listening to other arguments in this discussion you can't really call it a discussion, so I'll just leave you with this link and then get on with my life:
http://nexe.gamedev.net/directKnowledge/default.asp?p=DirectX%20Development%20Using%20DevC pp
As for the rest, please do not listen to this guy. If you think he's making any sense, you're wrong.
Isn't it the case that the C++ ABI is not exactly the same between gcc and VC++? If so, does that lead to potential calling convention issues when trying to call DirectX functions from a gcc-compiled application?
If not, I don't think there are any barriers to using DirectX with gcc, as you get all the procedure addresses through vtables anyway. In other words, differences in C++ name mangling between the compilers are not an issue.
Calling conventions are the same IIRC. Cdecl and stddecl are pretty "standardized", and if I'm not mistaken every WinAPI function uses an explicit calling convention in it's declaration, so even if the defaults differ you shouldn't get any problems. They even use the same notations in declarations.
And for leoptimus: of course, even if they differed, it's only because it's not specified in the standard, so it has nothing to do with MS hating OS (the argument could easily be reversed: GNU hates MS, so they decided to make the ABI incompatible and not MS)
Blaxill
12-01-2008, 05:07 PM
Because Microsoft hate Open Source.
http://www.microsoft.com/opensource/
http://www.codeplex.com/
etc (http://www.microsoft.com/resources/sharedsource/default.mspx)
Visual Studio C++ IDE 2005 - 2008: The most used, the most popular. It isn't easy to use at all. Huh?
alphadog
12-03-2008, 06:40 AM
http://www.microsoft.com/opensource/
http://www.codeplex.com/
etc (http://www.microsoft.com/resources/sharedsource/default.mspx)
Huh?
Microsoft, as an entity, currently doesn't "hate" FOSS as much as in 2001 when it called it "unamerican" and a "cancer", but, at best, it is currently quite schizophrenic about it. Any company is the sum of its vocal people, and right now Microsoft has a mix of anti- (see SCO debacle and recent patent sword-waiving) and pro-FOSS (various activities and departments) people which makes its overall stance on the issue a muddled mess.
And, if it could, it would rather see FOSS gone so as to maintain a status quo they have mastered, rather than have to face having to expend time and resources on developing new business models.
Unfortunately for them, I don't think FOSS will ever go away...
poita
12-06-2008, 04:49 AM
As I understand, they don't hate OS, they just hate the GPL, which I think is not unreasonable.
alphadog
12-08-2008, 05:53 AM
Not just the GPL. Anything that goes against vendor lock-in and selling software licenses. IOW, FOSS in principle, not just in one of its most talked about, tangible offshoots, the GPL.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.