X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <20040114161419.5889.qmail@web60908.mail.yahoo.com> Date: Wed, 14 Jan 2004 08:14:19 -0800 (PST) From: Thomas Tutone Subject: Re: errors To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii "Hans-Bernhard Broeker" wrote: > It's not quite that simple. > > In the case at hand (direct compilation + linking > of a single-source > C++ program with a recognized C++ filename > extension), gcc is supposed > to get it right, too. If it doesn't, that's a > regression in the DJGPP > port of gcc, or in gcc itself. > > Only if you link .o files, of which the compiler > doesn't know what > language were made from, should it be necessary to > make the choice of > language explicity by calling g++, or for the sake > of DOS filename > compatibility, gpp. > > gcc test.cc -o test > > always worked, and should continue to work. Only > > gcc -c test.cc > gcc test.o -o test > > didn't. I guess I have two responses: (1) I _think_ you are incorrect about the historical behavior of gcc and DJGPP (at least since gcc 3.0 - I don't remember how prior versions worked), but I won't bet money on it. (2) I _know_ you are incorrect about the current behavior of gcc and DJGPP. The _compiler_ is able to deduce the language of the source file based upon the file extension. It recognizes both "*.cc" and "*.cpp" as C++ source files. The _linker_, on the other hand, makes no such assumptions and does not link in any libraries by default simply because the source file has a C++ file extension. Whether you are creating an executable out of a single translation unit, as the OP was, or out of multiple translation units, if you want the C++ library linked in, you must either (1) use "gcc" and explicitly specify the libary you want linked in on the command line, or else (2) use "gpp" (or "gxx"), in which case the C++ standard library will be linked in implicitly. Your example ("gcc test.cc -o test") does not work if "test.cc" uses any part of the C++ library (such as std::cout), and has not worked in recent memory. When I try your example, it compiles fine but then I get the same linker errors the OP got. I used what I believe is the current release version of DJGPP, which uses gcc 3.3.2. If you disagree, please provide a working test case that illustrates your point, and identify what version of gcc and DJGPP you ran the test case on. Best regards, Tom __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus