X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: making dxe2gen with clio.rice.edu binaries -or- "undefined reference to 'operator'"? Date: 5 Apr 2002 10:40:48 GMT Organization: Aachen University of Technology (RWTH) Lines: 49 Message-ID: References: <3ca78d87$0$364$9b622d9e AT news DOT freenet DOT de> <3cab2f26$0$152$9b622d9e AT news DOT freenet DOT de> <3cace922$0$12701$9b622d9e AT news DOT freenet DOT de> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1018003248 11781 137.226.32.75 (5 Apr 2002 10:40:48 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 5 Apr 2002 10:40:48 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com deckerben wrote: > Thanks for the suggestions. > I pretty much knew about changing the compiler option by hand. But not every > package is written in C++ and sometimes they are written in both. That's not a problem. GCC is clever enough to know how to compile C and C++ sources, both using the gcc or g++ driver. The only point where it *really* makes a difference is the linking stage. If there are any C++ objects involved, you will have to use g++ for linking .o files. That's why the really good makefiles out there (including the default setup of GNU make) use independent, configurable names for the C++ and C compilers, like CC and CXX. CXX will default to $(CC), but you can override that. They also have a separate variable, LD, which points to the command to be used as the linker. LD=$(CXX) will usually take care of all your problems. > I was hoping for a way that DJGPP could see the difference and adapt itself > 'on-the-fly' as they say. It can't. .o files don't bear a stamp that would show whether they were made by compiling C or C++ files (or Fortran, or Pascal, or straight from assembly, or ...). > Some compilers know, for instance, that they should automaticly try a full > C++ convention with source files that have the .cpp file extension, and an > ANSI C convention when they end with .c GCC does that. But the moment you separate compilation into .o files and linking, most of those compiles will fail, too. In GCC, e.g. gcc -o myprog.exe myprog.cpp will work. But gcc -c myprog.cpp gcc -o myprog.exe myprog.o won't. > But my DJGPP installation was trying to compile a C++ file only using > default C libraries. No. It was trying to *link* it using C libraries. There's an important difference between compilation and linking you're missing. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.