6-29-03 C++ .NET
I've just spent some time downloading and installing the
.NET framework and SDK from
April 9, 2003. I had previously only the 1.1 beta installed.
By poking around, I discovered that this does appear to come with the C++
compiler. If you look at C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat,
(the various path entries you need to make to your environment), you'll see that some of
them are for cl, the Microsoft command-line compiler for C++. And sure enough,
after setting these PATH, INCLUDE and LIB variables, I was able to compile the following C++
program:
class Test {
int i;
public:
Test(int v) : i(v) {}
void set(int v) { i = v; }
int get() { return i; }
};
int main() {
Test t(1);
t.set(2);
int x = t.get();
}
Ah, but if you try to do anything more complex than this -- anything with C++ include
files, for example -- you immediately run into a wall. There are include files in
the paths given, but these are only C include files, not C++. So I was able to do this:
#include <stdio.h>
class Test {
int i;
public:
Test(int v) : i(v) {}
void set(int v) { i = v; }
int get() { return i; }
void print() { printf("i = %d\n", i); }
};
int main() {
Test t(1);
t.print();
t.set(2);
t.print();
int x = t.get();
printf("x = %d\n", x);
}
But as soon as I tried a #include <iostream> or even the old-style
#include <iostream.h>, it couldn't be found. So what you actually
get with the free .NET SDK is the C++ compiler enabled only
as a C compiler.
Because we freely distribute the electronic version of
Thinking in C++, Volume 2 and source code, we're always looking for ways for underfunded
readers to compile the code. Of course, when you install most Linuxes you get the most recent
version of G++, which works. Under windows, the
command-line version of the Borland C++ compiler
can be freely downloaded and works with the code. If you install
Cygwin
(a personal favorite of mine, since it solves so many Windows problems for me) on
your Windows platform, you get a Unix shell running under Windows, including the g++ 3.2 compiler,
which also works on TIC++V2.
William D. Tanksley, Jr. Sent me the following solution:
http://winprog.org/tutorial/msvc.html
This page says that you can download the .NET stuff, then download the
Platform SDK (both free), and you'll then have a complete SDK, with all the
libraries and include files.