Message-Id: <199809040053.UAA00547@delorie.com> Comments: Authenticated sender is From: "George Foot" To: Jason Date: Fri, 4 Sep 1998 01:51:15 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Why doesn't C++ work!?!?! Reply-to: mert0407 AT sable DOT ox DOT ac DOT uk CC: djgpp AT delorie DOT com Precedence: bulk On 3 Sep 98 at 15:41, Jason wrote: > Hey guys: > > I have not been able to get any C++ programs compiled - and on the DJGPP > website, it says that gcc should know what to to with the file according > to the file's extenstion. It does. However, for most C++ programs you need to link in the standard C++ library (or at least part of it). See below. > I tried to compile a simple C++ program that > couts one line (it looks like this): > > #include > > main(void) > { > cout << "This is a test."; > } > > (Simple enough?!?) it seemed to treat it like a C source. Here is some > sample output: > > d:/dgjpp/tmp\ccca2vyh(.text+0x21):cpptest.cpp: undefined reference to > 'cout' > d:/dgjpp/tmp\ccca2vyh(.text+0x26):cpptest.cpp: undefined reference to > 'ostream::operator<<(char const *)' > > What I get from this is it's not even recognizing the 'cout' command! > gcc works perfectly fine with C sources (*.c), but it has this same > problem with *.cpp and *.C . Anyone else had this problem? Help me! > :O) I don't play with C++ much, but try some of the following: gxx foo.cpp -o foo.exe or gcc foo.cpp -o foo.exe -liostr (maybe `-liostream' these days) or gcc foo.cpp -o foo.exe -lstdcx (`-lstdcxx' if you use gcc v2.8.1) The first one is the normal one to use; you need to use `gxx' instead of `gcc' whenever you are producing a .exe file from a C++ program. So when you're compiling and linking separately, compile with `gcc': gcc -c foo.cpp but link using `gxx': gxx foo.o -o foo.exe If you're compiling and linking all in one step, just use `gxx' as I originally did above. This is documented in readme.1st, which you should read. -- george DOT foot AT merton DOT oxford DOT ac DOT uk