delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/29/22:35:26

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: linking problems with djgpp C++
Date: 29 May 1997 23:06:39 GMT
Organization: Oxford University, England
Message-ID: <5ml25v$8p2@news.ox.ac.uk>
References: <338DB382 DOT 6ECE AT pop DOT telebyte DOT nl>
NNTP-Posting-Host: sable.ox.ac.uk
Lines: 20
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

The NiBBLeR (bws AT pop DOT telebyte DOT nl) wrote:
: Here's the source:

[snipped]

: Compiling this, isn't any problem.
: When linking it, it gives the error something like:
:   -name::test(int c) defined on another place,

From the looks of the source, what you posted was a header file (.h) to be
#included in C++ source files. If you #include it in more than one C++
file, the mmeber functions will be multiply defined and you get the error
you paraphrased. The solution in this case is to write an extra C++ file
which #includes the header with the class definition, and move the member
function definitions from the header file into this new C++ file. Then you
compile this C++ file and link it in.

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019