I want a good, preferably small compiler to use, one preferably that doesn't have to be installed.
Its already been suggested that its possible to use the compiler's that came with an Ide like codeblocks. However I have been having difficulty with it.
First I tried copying c++.exe into its own folder, but it wouldn't let me compile anything without finding cc1plus.exe and copying it to the same folder. Then it gave me error no include path to search for iostream. After realizing the correct command line should be c++ -I/codeblocks/mingw/include/c++/3.4.5 hw.cpp it then proceeded to give a zillion error messages which i couldn't figure out how to pause.
I just want a simple command line compiler so I can work at libraries and computer labs where I can't install other software. What should I do?
by using the keyboard pause button I've been able to get the first few error messages:
bits/c++io.h no such file
bits/c++locale.h no such file
bits/c++config.h no such file or directory
also forgot to mention, when i try to compile an empty program like int main() { return 0; }, with no include directives, i get messages saying cannnot exec 'as', 'ld'. so I copied those to the same directory as well. But then I get the message saying: ld: cannot find -lstdc++
I have no idea what that means.
Just install the compiler in a memory stick.
You can do that with the entire IDE if you like.
I've tried this with Code::Blocks for Windows using MinGW and it worked
I remember I had tried that before and it didn't work... but amazing i just did (infact I still have it on my my flash drive) and it worked.... but I'm not sure if its because there's already another instance installed on the Hard Drive.
On Windows:
MinGW doesn't have to be installed, and even if you do it merely unzips the files into a directory. You have to add the bin PATH to the environment yourself, unless you are happy with project files in the bin. You can also get out of setting the environment variable using Bloodshed Dev-C++ IDE. It installs but works just as well standalone. I like SciTe as an editor also, which includes unlimited custom lexer dependent build commands. I don't like installers myself, and with MinGW, Bloodshed, and/or SciTe you can do everything without installs.
It can be a learning experience to get it to work without doing the installs.
Well I've found what I beleve to be the MinGW compiler in my installation of C-free (the following is true for codeblocks as well. So I copied g++.exe (there is also gcc.exe & c++.exe, but they all give similar messages) to a separate folder and wrote a small hello world program to that directry.
When I executed the command g++ hw.cpp I got this error:
cannot execute 'cpp'.... so I found the cpp.exe in my codeblocks installation and placed it in that folder as well.
then I got: No include path to search for stdio.h.
so I then copied the include folder there as well and executed the command:
g++ -I/c++/include hw.cpp
g++ installation problem, cannot exec 'cc1plus'
so I coppied cc1plus to the same folder as well, and I did this subsequently for each of the following files:
as.exe, ld.exe, crt2.o
After that I got the error message:
ld: cannot open -lstdc++: No such file or directry.
But I cannot find -lstdc++ or lstdc++ anywhere in either the installations of C-Free or Codeblocks.
The binaries (executable files) will naturally be in
C:\MinGW\bin\
The include (header) files in
C:\MinGW\include\
Etc.
In order to use the compiler, you need the entire C:\MinGW\ directory tree -- the directory, all the files in it, all subdirectories and all files in them, etc. It does not really matter where you put it. To run the compiler, wherever you put the entire directory tree, put its bin\ subdirectory in the path. If you put the compiler in the default spot, your path should have the following directory listed:
C:\MinGW\bin
This is what I meant by 'your compiler has to be installed'. I don't know of any full-fledged C and/or C++ compiler that comes in only one or two executable files. Doing that is not practical. You need all the supporting files.