DLL's and inlined methods

Schaible, Joerg Joerg.Schaible@gft.de
Fri May 7 04:34:00 GMT 1999


Hello,

me again. I got trouble building a dll with classes that have inlined
methods. I've modified Mumit's sample to demonstrate the problem:

// dllclass.h:

class DLLIMPORT
DllClass : public DllClassBase {
public:
  DllClass (int i = 0);
  ~DllClass ();
  int non_virtual_method () const;
  virtual int virtual_method () const;
// ======== Added inlined method here =============
  int inline_method() const { for( int i = 40, j = 0; i--; ) j++; }
#ifdef __GNUC__
  DLLIMPORT             // work around an egcs-1.1 bug
#endif
  static int instances;
private:
  int i_;
};

// dllclass.cc:

// added this function
void dummy1()
{
    DllClass dc;
    dc.inline_method();
}


// dllinline.cc  <== Added new module to DLL

#include "dllclass.h"

void dummy2()
{
    DllClass dc;
    dc.inline_method();
}


I will have following error message running make:

c++ -c -DBUILDING_DLL=1 -I. -g  -o dllclass.o dllclass.cc
c++ -c -DBUILDING_DLL=1 -I. -g  -o dllexterns.o dllexterns.cc
c++ -c -DBUILDING_DLL=1 -I. -g  -o dllinline.o dllinline.cc
gcc -c -DBUILDING_DLL=1 -I. -g  -o dllinit.o dllinit.c
dllwrap --export-all --output-def cxxdll.def --implib libcxxdll.a
--driver-name c++ -o cxxdll.dll \
        dllclass.o dllexterns.o dllinline.o dllinit.o
Warning: no export definition file provided
dllwrap will create one, but may not be what you want
dllinline.o: In function `DllClass::inline_method(void) const':
/egcs-1-1-2/dllhelpers-0.2.5/c++/dllclass.h:26: multiple definition of
`DllClass::inline_method(void) const'
dllclass.o(.text$inline_method__C8DllClass+0x0):/egcs-1-1-2/dllhelpers-0.2.5
/c++/dllclass.cc: first defined here
collect2: ld returned 1 exit status
dllwrap: c++ exited with status 1
make: *** [cxxdll.dll] Error 1


Any suggestions ?
Jörg

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list