A free version of C++ on Win (7)??

A

Alf P. Steinbach

I'm using Win 7. In any case, is there a free version of C++ or Win?

The two main free C++ compilers for Windows are Visual C++ and g++.

The Visual C++ compiler is bundled with an IDE called "Visual C++
Express". The full commercial version of that IDE is Visual Studio. For
a novice the main thing to be aware of is that while it *allows* you to
do standard C++ programming, it effectively uses all kinds of tricks to
trap you in a Microsoft-specific world, and this includes automatically
generated code (it's a good idea to ask for "empty" projects).

The g++ compiler is part of the GNU (GNU is Not Unix) toolchain for
*nix, or perhaps, for not *nix? It has two major ports to Windows,
namely as part of Cygwin, and a freestanding version, which is called
MinGW (Minimal GNU on Windows). There are many variants of MinGW g++
produced by different people, and ironically the most difficult way to
get hold of this compiler is via the MinGW project's own pages...

An easy way to get the MinGW g++ compiler is to install an IDE such as
Code::Blocks that has g++ as its default compiler. Unfortunately this is
likely to get you a pretty old version. But it's easy, and you need the
IDE anyway in order to use the debugger in a reasonable way.

Both compilers come complete with a set of command line tools.


Cheers & hth.,

- Alf
 
E

Ebenezer

The two main free C++ compilers for Windows are Visual C++ and g++.

The Visual C++ compiler is bundled with an IDE called "Visual C++
Express". The full commercial version of that IDE is Visual Studio. For
a novice the main thing to be aware of is that while it *allows* you to
do standard C++ programming, it effectively uses all kinds of tricks to
trap you in a Microsoft-specific world, and this includes automatically
generated code (it's a good idea to ask for "empty" projects).

It also produces executables that are significantly larger than
GCC on Linux. The best thing I can say about the Microsoft
compiler is it sometimes provides better errors/warnings than
GCC.

Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
 
L

Lynn McGuire

I'm using Win 7. In any case, is there a free version of C++ or Win?

www.openwatcom.org has a free C++, C and F77 compiler
that supports producing DOS16, DOS32, Win16 and Win32
programs. There is an IDE and a source code debugger
with DOS16, Win16 and Win32 interfaces.

Lynn
 
P

puppi

I'm using Win 7. In any case, is there a free version of C++ or Win?

If you absolutely must develop for Windows for professional reasons,
using Windows-specific APIs, then please follow the above advices.
Otherwise there really isn't any reason why you should be using
Windows and not Linux, afterall...
 
N

Nick Keighley

On 23.11.2011 18:42, W. eWatson wrote:

The two main free C++ compilers for Windows are Visual C++ and g++.

The Visual C++ compiler is bundled with an IDE called "Visual C++
Express".

one of microsoft marketing's more shoot-yourself-in-the-foot
decisions. Visual C++ is actually a perfectly good C++ compiler. It
also provides a quite reasonable C compiler.
The full commercial version of that IDE is Visual Studio. For
a novice the main thing to be aware of is that while it *allows* you to
do standard C++ programming, it effectively uses all kinds of tricks to
trap you in a Microsoft-specific world,

that's a bit harsh.
and this includes automatically
generated code (it's a good idea to ask for "empty" projects).
quite

The g++ compiler is part of the GNU (GNU is Not Unix) toolchain for
*nix, or perhaps, for not *nix?

it also traps you into a non-standard mode by default. Though
admittedly it doesn't generate code.
It has two major ports to Windows,
namely as part of Cygwin, and a freestanding version, which is called
MinGW (Minimal GNU on Windows). There are many variants of MinGW g++
produced by different people, and ironically the most difficult way to
get hold of this compiler is via the MinGW project's own pages...

An easy way to get the MinGW g++ compiler is to install an IDE such as
Code::Blocks that has g++ as its default compiler. Unfortunately this is
likely to get you a pretty old version. But it's easy, and you need the
IDE anyway in order to use the debugger in a reasonable way.

Both compilers come complete with a set of command line tools.

I gave up on MingW as I difficulty persauding it to generate
debuggable code. This may have been the Bloodshed IDE that was giving
me gip. I found VS less painful and a nicer GUI.
 
N

Nick Keighley

If you absolutely must develop for Windows for professional reasons,
using Windows-specific APIs, then please follow the above advices.
Otherwise there really isn't any reason why you should be using
Windows and not Linux, afterall...

why not or is this just the stallman koolade talking?
 
R

ralph

one of microsoft marketing's more shoot-yourself-in-the-foot
decisions. Visual C++ is actually a perfectly good C++ compiler. It
also provides a quite reasonable C compiler.

Perhaps not as "shoot-yourself-in-the-foot" as you think. Name another
commercial alternative for Windows programming? There are few
remaining.
that's a bit harsh.

Agree.

Windows IS a "Microsoft-specific world". I have always failed to
understand why people get upset over that simple fact. Microsoft owns
Windows. Period.

So they give away a development platform with the deliberate intention
to get you to buy the full version. Duh!
....

I gave up on MingW as I difficulty persauding it to generate
debuggable code. This may have been the Bloodshed IDE that was giving
me gip. I found VS less painful and a nicer GUI.

All open source is essentially a construction kit. Some damn nice
stuff out there, but it alls need to be stamped "DIY". <BG>

-ralph
 
R

Richard

[Please do not mail me a copy of your followup]

"W. eWatson" <[email protected]> spake the secret code
I'm using Win 7. In any case, is there a free version of C++ or Win?

Get Visual C++ Express Edition. It's free and has no limitations on
the code that you produce with it (i.e. you can develop commercial
products with it).

Using gcc or other *nix-derived compilers is fine *if* you never intend
to write programs that use the Win32 API or anything other than POSIX
style system interfaces. Otherwise, its just too much pain and I'd
recommend using the Visual C++ Express Edition instead.

As for Visual C++ "tricking" you into using Windows specific items,
I'd say that's just disgruntled *nix fanboy sentiment talking. It
isn't hard at all to write very portable code using Visual C++. I
have done it for years. If you don't know what's Windows or Visual
C++ specific in any project template, then read the docs on it.
Everything that is Windows/VC specific is documented as such.

As for the badness of "generated" code, Visual C++ simply recognizes
that each application type has some boilerplate that is the same from
project to project. Writing a console application? You're going to
need a main(). And so-on. The project templates simply save you some
work by generating this boiler plate when you create the project.

There's nothing magic or evil about this code, you can edit it or
delete it to your heart's content.
 
N

Nick Keighley

Perhaps not as "shoot-yourself-in-the-foot" as you think. Name another
commercial alternative for Windows programming? There are few
remaining.

it just seemed a dumb naming convention. Visula C used to be (may
still be) a different language from C. I suspect Microsoft achieved
dominance of the Window's compiler market by means other than pure
technical excellence.

But it is a good C++ compiler and it is a reasonable GUI.
Agree.

Windows IS a "Microsoft-specific world". I have always failed to
understand why people get upset over that simple fact. Microsoft owns
Windows. Period.

but you can write standard C/C++ programs (so-called console programs)
and you can write applications with little Windows's dependence (eg.
using OpenGL). You can also write Win32 programs without using their
<expletive> "wizards" (boiler-plate generator). Sometimes it would be
be nice if they made this easier, or more obvious.

"meddle not in the affairs of wizards, for they are subtle and quick
to anger"
Gandalf The Grey
So they give away a development platform with the deliberate intention
to get you to buy the full version. Duh!

I don't feel any particular compulsion to buy the full version (and
I've used the full version- when someone else is paying for it).
I gave up on MingW as I [had] difficulty persauding it to generate
debuggable code. This may have been the Bloodshed IDE that was giving
me gip. I found VS less painful and a nicer GUI.

All open source is essentially a construction kit. Some damn nice
stuff out there, but it alls need to be stamped "DIY". <BG>

gcc on linux is fine. It may even be fixed on Windows for all I know.
 
K

Krice

It also produces executables that are significantly larger than
GCC on Linux.

I don't know about Linux, but in Windows VC actually makes
smaller executables in Release (non debug) mode than GCC
in similar mode (without debug information). On the other
hand GCC seems to include something that makes it more
portable even between Windows versions. Executables of VC
require some VC runtime libraries that aren't installed by
default in all Windows versions. (But I guess usually are.)

Starting with a clean project VC is like GCC, you can use
standard C/C++ libraries and write portable code.
I have made it a habit to write code in VC (because it has
a great debugger) and then create a final executable in GCC.
It's cool, because they both seem to catch different kind
of issues and warn about them, making the source code even
more portable and improving the code quality.
 
J

jacob navia

Le 25/11/11 09:40, Nick Keighley a écrit :
gcc on linux is fine. It may even be fixed on Windows for all I know.

This is the contrary to my experience and the experience of all the
people at work.

We have a huge C++ program (a database management system) written in
C++ and we run under linux and windows.

Nobody ever develops under linux, the problem is that there, the
only choice you have is the terrible gcc/gdb combination, what
makes any debugging and developing an incredible effort.

Under windows we use the C++ IDE above all for the Go To Definition
feature, what saves us HOURS of grepping each week. As you (may)
know, with several dozens of overloaded functions of the same name
it is impossible to know which function will be called unless
you have an exact map of the class structure and template structure
of the application.

Problem is, the application is too big to fit in the head of a single
developer as a whole, nobody unerstand all the details since the
application has been debeloped by the team for over 6 years.

Many people have left and come, and it is today not possible to debug
a problem without having this feature.

When you develop, the IDE proposes you choices that avoid common
mistaks and allow you to think more into WHAT are you writing rather
than

"Was it SomeCompositeName, someCompositeName or some_composite_name"?

Yes, pedants will start with "Ahhh but you should have enforced
consistent naming conventions" and all that crap that is good in theory
but never found in real programs.

Another problem of gcc is that it generates slower executables than
MSVC, and specially slower than the Intel compiler, the best x86
compiler around.

Under linux, it is impossible to avoid the gcc/gdb combination but using
a windows machine we can still use the "Go to definition" feature
if we run in parallel the gdb debugger and the Visual C++ IDE.

And no, Eclipse is not usable. Written in Java, it chockes at the
hundred thousands of lines of the application.
 
A

Alf P. Steinbach

[Please do not mail me a copy of your followup]

This is good advice in general.

"W. eWatson"<[email protected]> spake the secret code


Get Visual C++ Express Edition. It's free and has no limitations on
the code that you produce with it (i.e. you can develop commercial
products with it).

Using gcc or other *nix-derived compilers is fine *if* you never intend
to write programs that use the Win32 API or anything other than POSIX
style system interfaces. Otherwise, its just too much pain and I'd
recommend using the Visual C++ Express Edition instead.

Well that's highly misleading.

MinGW g++ supports ordinary API level programming, which covers most of
the Windows API.

But in my experience g++ does not in general support the latest
Microsoft "technologies", whether buzzword or useful. For example, there
was a time when g++ did not support GDI+, which is/was a very useful new
"technology" (essentially added graphics capabilities that had been
lacking for about ten years or so). I think but I'm not sure that GDI+
support has been added to g++ now. Anyway, creating a g++ binding was
quite laborious because Microsoft, unnecessarily, used Visual C++
compiler-specific features and really Bad Practices ,such as using min
and max macros instead of the functions from <algorithm>, in their GDI+
headers. There are two possibilities: unbelievable incompetence, or
intentional attempt to trap users in Microsoft land.

As for Visual C++ "tricking" you into using Windows specific items,
I'd say that's just disgruntled *nix fanboy sentiment talking. It
isn't hard at all to write very portable code using Visual C++. I
have done it for years. If you don't know what's Windows or Visual
C++ specific in any project template, then read the docs on it.
Everything that is Windows/VC specific is documented as such.

As for the badness of "generated" code, Visual C++ simply recognizes
that each application type has some boilerplate that is the same from
project to project. Writing a console application? You're going to
need a main(). And so-on. The project templates simply save you some
work by generating this boiler plate when you create the project.

There's nothing magic or evil about this code, you can edit it or
delete it to your heart's content.

It's true that Visual C++ *enables* you to write standard code.

But sometimes you have to work really hard at it. Like, when it
presumably with the best of intentions try to help you by rewriting your
standard-compliant XHTML code to Microsoft-specific rubble. I remember
how ironic this was when MS released Internet Explorer 7, I think it
was, anyway the version after the long hiatus, the version with better
support for standards. The MS web page about this new version was
perfectly standard-conforming, which caused a lot of really impressed
and positive commentary -- for about 8 hours, when they updated it, and
the MS tools screwed it totally up forever...

When I wrote that novices should be aware of the (intentional or not)
Visual Studio attempts to trap the user in the Microsoft world, I did
not expect any discussion about that, because it is so well known and so
obvious to anyone experienced. So I did not give any examples. But OK,
now's the time.

Let's create a console project in Visual C++ Express 10.0.

We (you) are the teacher or lab assistant, providing instructions to a
novice. You want to /avoid/ that the novice ends up with Visual Studio's
automatically generated console program "starter code". Because that
starter code is not only Microsoft specific but teaches extreme wrongness.

<code>
// first_program_ever.cpp : Defines the entry point for the console
application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

</code>

Here the comment at the top is wrong, it's not the "entry point" but
rather the "startup function" (one of the most infamous Microsoft
documentation bugs, still there as far as I know, describes the WinMain
startup function signature as the signature of a program's entry point).

The "stdafx.h" header is not a standard header. It is a header used for
Visual C++ precompiled header technology. Which changes the semantics
such that *standard code* fails to compile, with baffling (to the
novice) "end of file" error messages. There is no advantage to
precompiled headers for a little console program, but lots of
disadvantages, including the non-standard semantics. I.e., when we
discount colossal incompetence as an explanation, it's an attempt to
trap the user in Microsoft-land.

"_tmain" is not a standard startup function name. The standard name is
"main". "_tmain" is in support of Windows 9x. Conceivably whoever
maintained this just forgot about stopping to use that thing after 2001,
when the Layer for Unicode was introduced to deal with the lack of
Unicode support in Windows 9x. But would anyone really believe that they
forgot about that for 10 years? I don't.

Similarly, "_TCHAR" in the argument list is non-standard, and is solely
in support of Windows 9x.

Finally, the "return 0;" is unnecessary, but it is the only thing here
that is not an attempt to unnecessarily trap the user in Microsoft land.

To avoid that entrapment, you have to provide step by step instructions
like those below, ordering the novice to do things in an apparently (to
the novice) needlessly and senselessly complicated way -- which as I see
it, of course is by design, an attempt to trap in Microsoft world.

Step 1.
Run Visual C++ Express by clicking its icon.

In Windows 7 one way I can do this is by typing "visual" in the Start
menu, and selecting the (on my machine) second choice.

Step 2.
Click "New Project", select Windows Console Project, fill in
details

This can look like <url: http://i.imgur.com/4V1bE.png>.

Step 3.
Click OK in "New Project" and ***DO NOT*** click "Next" in the
"Application Wizard" that pops up. Instead click "Application
Settings". This can look like <url: http://i.imgur.com/9ifsE.png>.

Step 4.
In the "Application Settings" page, **FIRST** remove the tick
mark in the "Precompiled Header" box. **THEN** place a tick mark
in the "Empty Project" box. Doing this the opposite order won't
work.

Now you might wonder, at version 10.0 of Visual Studio, as of 2011, is
it likely that there is still such an idiotic bug in one of the most
often used dialogs? Well yes, it is IMHO likely, that it is there *by
design*. That Microsoft rather heavy-handed steers the user towards
using "Precompiled header" at least, which changes the semantics of
ordinary C++ code so that it is no longer standard conforming (wrt.
header inclusion), but instead Microsoft specific, and for standard code
yields baffling error messages about encountering end-of-file.

Step 5.
Click Finish, right click the Source folder in the project, and add
an a new file (you can call it "main.cpp", or anything).

That's a pretty awkward procedure just to avoid the entrapments!

And so it goes, e.g. for COM programming where instead of associating
classes with UUIDs via standard C++ traits or even just a macro namer
thing, a non-standard language extension is used. This language
extension serves no purpose in C, where it would just as well be done
via macros, and in C++ it has no advantages compared to a traits class.
It is solely a device to trap the user in Microsoft land.

And so on.

All of this *can* in principle be avoided, and that's what I wrote.

But it is very much necessary to be aware of it.


Cheers & hth.,

- Alf
 
J

Jorgen Grahn

On Thu, 24 Nov 2011 01:59:06 -0800 (PST), Nick Keighley


All open source is essentially a construction kit. Some damn nice
stuff out there, but it alls need to be stamped "DIY". <BG>

On Windows perhaps that's true, but in any (free) Unix it's certainly
not -- unless you think anything which isn't one big IDE is a
DIY construction kit.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top