It is possible to download a C++ compiler from the web that conforms with the ANSI/ISO C++ standard. This compiler is part of the GNU project. This compiler has two versions: gcc and g++. By installing gcc, you will also install g++. g++ is just a front end to gcc for C++ programs. This is the same compiler as is found on solix. The instructions below tell you how to install gcc.
To find it, go to the GNU Win32 C++ page
http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/download.html
download the indicated files. Copy them to a directory of your choice and extract them using an unzip program. Then check out the installation page at
http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/installation.html
This page will give you detatiled steps for installing gcc (and g++) and testing it.
Basically, you have to add the following to your autoexec.bat file,assuming you unzipped the program into C:\MINGW32. If you used a different directory, then you will need to ammend each path accordingly.
set C_INCLUDE_PATH=C:\MINGW32\include
set CPLUS_INCLUDE_PATH=C:\MINGW32\include\g++;C:\MINGW32\include
set LIBRARY_PATH=C:\MINGW32\lib
set GCC_EXEC_PREFIX=C:\MINGW32\lib\gcc-lib\
Be sure there are no spaces at the end of each line. That error wasted several hours of my time! You can edit AUTOEXEC.BAT by pressing Start, Run and typing in sysedit from Win95 or WinNT. Make these changes and restart your computer and you will be able to compile C++ programs from an MS DOS command prompt window.
You may stop here, and run g++ commands by opening the following
By switching between Notepad and the MS DOS window, you can edit and debug your program.
Warning: The remaining installation process may be harmful to your peace of mind. Proceed at your own risk.
By installing cygwin32, it is possible to run a GUI version of gdb, the debugger for gcc and g++.
To install cygwin32, go to the Cygnus Page
http://www.cygnus.com/misc/gnu-win32/
and select a Download site. Then download the file cdk.exe. Be sure to check out the Frequently Asked Questions, especially 'Installing the binary release'. cdk.exe is a self extracting program, so just copy it to the directory where you want cygnus to be installed and execute the file. This will add a shortcut named Cygwin32 beta 19 (or whatever version you get) to your Start menu. Now when you double click the shortcut, you will have a Unix-like bash shell on your system. cdk actually has its own gcc compiler, but it doesn't support the ANSI/ISO standard, so it is better to use the one descibed above.
From the bash prompt, cd to the directory where your C++ source files are open, and start gdb. You can return to the window later when you have created an executable and open it from the File, file... menu. If you want to use the mingw32 g++ and gcc compilers, then edit the file cygnus.bat which is located in the directory where you installed the cygnus environment. I recommend that you do this. Remark out the line that points to the cygnus gcc command.
REM *** removed by Tim Downey to disable Cygnus gcc ***
REM SET GCC_EXEC_PREFIX=%CYGROOT%\H-i386-cygwin32\lib\gcc-lib\
By using the emacs editor, it is possible to locate compilation errors quickly. To install the emacs editor, go to the page at
http://www.cs.washington.edu/homes/voelker/ntemacs.html
This page has a lot of answers. To download the emacs file, go to the ftp site at
ftp://ftp.cs.washington.edu/pub/ntemacs/latest/i386
I chose the newest non-beta version. I also chose the precompiled version: it is easier to install. Download the emacs-19.34.6-bin-i386.tar.gz file, or a newer version. Copy this file to the directory where you would like to install emacs. Also, go to the utilities directory and get a copy of tar and gunzip. You will need these to unpack the emacs file. The utility files will be located at
ftp://ftp.cs.washington.edu/pub/ntemacs/latest/utilities/i386
The files I downloaded were
gunzip-1.2.4-i386.exe
tar-1-11.2-i386.exe
Download them to the directory where you downloaded the emacs file. After you download these, they are ready to run. However, I would rename them to gunzip and tar for ease of use. Then you can unpack the emacs file as follows:
gunzip -c -d emacs-19_34_6-bin-i386_tar.gz | tar xvfm -
the names of your files may be different, so check before you issue the commands. For gunzip, the -c option means copy the output to standard out (so it can be used in the pipe) and the -d means to maintain the same directory structure as when the files were packed. For tar, the x means extract, v means to output the names of all the files as they are extracted (verbose), f means that the name of the tarfile is specified in the command (if - is the file, then standard input is assumed for extract, and standard output for compress), m sets the modification time of the files as the time of extraction (valid only with x command).
Edit the file emacs.bat, which is in the bin directory, as follows: First, modify this line in the emacs.bat file. The file will be in the bin subdirectory where you installed emacs. Replace d:\ with the full path to your emacs directory.
REM *** change this path to the path where you are putting the emacs files
***
set emacs_dir=c:\emacs\emacs-19.34
REM *** end of change ***
Add these lines so that cygnus can be found. You only need these lines if you are going to be adding tcsh as described in the next section. Change the first part of the path to the directory where you installed the Cygnus environment.
REM add cygnus path for tcsh shell
SET PATH=C:\CYGNUS\H-I386-C\bin;%PATH%
REM end cygnus
Then add these lines so that emacs can find g++. Change the value of MY_PREFIX to the path for the directory where you installed g++.
REM *** added by Tim Downey to allow g++ to be found from emacs***
set MY_PREFIX=c:\mingw32
set C_INCLUDE_PATH=%MY_PREFIX%\include
set CPLUS_INCLUDE_PATH=%MY_PREFIX%\include\g++;%MY_PREFIX%\include
set LIBRARY_PATH=%MY_PREFIX%\lib
set GCC_EXEC_PREFIX=%MY_PREFIX%\lib\gcc-lib\ path = %path%;%MY_PREFIX%\bin
REM *** end of addition ***
Be sure there are no spaces at the end of any of these lines!
Near the bottom of the file, you will see a bunch of statements about the HOME variable, comment them out like this:
REM set HOME_SAVE=%HOME%
REM set HOME_EXISTS=yes
REM set HOME_DEFAULT=C:\
REM set HOME=
REM if "%HOME%" == "%HOME_SAVE%" set HOME_EXISTS=no
REM if "%HOME_EXISTS%" == "yes" set HOME=%HOME_SAVE%
REM if "%HOME_EXISTS%" == "no" set HOME=%HOME_DEFAULT%
REM if "%HOME_EXISTS%" == "no" echo HOME is not set! Using %HOME% as a default...
And add this line to the bottom, changing the path to the path where you will be placing your C++ source files.
set HOME=h:\data\tim
Start emacs and open the C++ source file. To compile the file issue the command: ESC-X compile this will come up with a default option of make -k. If you have a make file, then this is fine, otherwise, change the command to
g++ -g -o my_file.exe my_file.cpp
where 'my_file' is the name of your file. After this command, your screen will be split in two: the top half will be your source code, the bottom half will be a list of your errors. By clicking on an error line and pressing the ENTER key, you will be taken to that line in the source file. By pressing CTRL-` you will be taken to the next error.
There is a problem with Emacs on Win95: the shell command doesn't work very well. The Emacs page documents several fixes for this, but I could only get this one working:
First, go to this ftp site and download a copy of tcsh.
ftp://ftp.blarg.net/users/amol/tcsh/
It will probably be named tcsh_exe.gz. Unpack it with the gunzip program that you downloaded for emacs.
gunzip -d tcsh_exe.gz
Rename the file tcsh_exe to tcsh.exe and copy it to your emacs bin directory. In order to get this working, you need to have installed the cygnus environment described above, because it contains all of the Unix shell commands: tcsh is just a front end for these commands.
Create a file named .emacs (yes, it starts with a period) in the directory that you indicated in the emacs.bat file for the HOME variable. Place the following in this file:
(setenv "SHELL" "tcsh.exe")
(setq win32-quote-process-args t)
(setq compile-command '("g++ -g -o "))
The last line is not necessary, but it will change the default value of ESC-X compile to g++ -g -o. This will save you some typing time.
Now when you restart emacs, you will be a able to access a Unix-like shell named tcsh by issuing the command
ESC-X shell
This will open up an interactive shell in emacs. From it, you can run your program by typing the name of it's executable file. You will be able to use the buffer menu to switch amongst your source code, your compilation errors, and your output window.
And that's it! Simple! You now have a complete IDE for C++: editor, syntax checker, debugger, and output window. You also know why complete IDE programs like CodeWarrior and MSVC 5.0 cost about a hundred bucks!