delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/24/10:35:24

Message-ID: <3812BDDA.E709C2E1@hjc.edu.sg>
Date: Sun, 24 Oct 1999 16:05:46 +0800
From: Chong Kai Xiong <8111883c AT hjc DOT edu DOT sg>
X-Mailer: Mozilla 4.04 [en]C-NECCK (Win95; I)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Linking problem
Reply-To: djgpp AT delorie DOT com

Hello DJGPP people!

    I found this problem only today when I tried to build my pixel
buffer library...

    I defined two classes call "cPoint" and "cRect" in a header
file(crect.h). I also implemented them in the same file because I wanted
to utilise the function inlining... Then I included this header file in
my main program(main.cc) and my pixel buffer class
implementation(cpixelbuffer.cc). I compiled main.cc and cpixelbuffer.cc
separately into object files and then tried to link the two...the linker
gave me something like "multiple declaration cRect::cRect()" and similar
ones for the rest of the constructors.

  I double checked the header files if I forgot to add preprocessor
instructions to avoid duplication. They were correct. I thought it was
my problem that I don't understand C++ semantics or something...I tried
compiling it under M$ VC (I know I know it's M$, but VC sure is
good)...it worked. Then I tried to compile it under Linux using the GNU
C/C++ compiler...it didn't complain either...

  Anyone knows what's the problem? I upgraded from 2.81 to 2.9...could
it be a problem with some old settings I forgot to change? I don't want
to dump the implementation in a C++ source file. Thanx for your help...

  By the way, I wrote the following to test the compiler/linker.


(tinline.h)

#ifndef __TEST123_H
#define __TEST123_H

class TInline {
public:
  TInline();
~TInline();
};

TInline::TInline() { /* empty */ }
TInline::~TInline() { /* empty */ }

#endif


(test.cc)

#include "tinline.h"

void Debug() {
  TInline Class;
}


(main.cc)

#include "tinline.h"

int main() {
  TInline TestClass;
  return 0;
}


And compiled the files with:
gxx -c test.cc -o test.o
gxx -c main.cc -o main.o

And tried linking it with:
gxx test.o main.o -o debug.exe

which didn't work...


Thanx for your help in advance
=)


Micro$oft Windoze 2000
The Millennium bug

- Raw text -


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