delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
Sender: | cygwin-owner AT sourceware DOT cygnus DOT com |
Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com |
Message-Id: | <199905071716.MAA16653@modi.xraylith.wisc.edu> |
X-Authentication-Warning: | modi.xraylith.wisc.edu: localhost.xraylith.wisc.edu [127.0.0.1] didn't use HELO protocol |
To: | "Schaible, Joerg" <Joerg DOT Schaible AT gft DOT de> |
cc: | "'cygwin-list'" <cygwin AT sourceware DOT cygnus DOT com> |
Subject: | Re: DLL's and inlined methods |
In-reply-to: | Your message of "Fri, 07 May 1999 13:34:00 +0200." |
<C2D7D58DBFE9D111B0480060086E96358D6FAB AT gftmail DOT gft DOT de> | |
Date: | Fri, 07 May 1999 12:16:00 -0500 |
From: | Mumit Khan <khan AT xraylith DOT wisc DOT EDU> |
"Schaible, Joerg" <Joerg DOT Schaible AT gft DOT de> writes: > 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 =3D 0); > ~DllClass (); > int non_virtual_method () const; > virtual int virtual_method () const; > // =3D=3D=3D=3D=3D=3D=3D=3D Added inlined method here = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > int inline_method() const { for( int i =3D 40, j =3D 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 <=3D=3D 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=3D1 -I. -g -o dllclass.o dllclass.cc > c++ -c -DBUILDING_DLL=3D1 -I. -g -o dllexterns.o dllexterns.cc > c++ -c -DBUILDING_DLL=3D1 -I. -g -o dllinline.o dllinline.cc > gcc -c -DBUILDING_DLL=3D1 -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 > This is a bug in egcs-1.1.2 that shows up when dealing with inline methods in DLLs. The linkage directive is slightly wrong, and you end up with multiple definitions instead of the linker discarding duplicates as expected. It's fixed in upcoming egcs-1.2 (please don't ask me when that'll be released). The workaround is to avoid inline methods is DLL exported/imported classes. Define these out-of-line in .cc file and you should be all set. Regards, Mumit -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |