delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/11/04/16:33:14

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3A048147.7005DB68@ece.gatech.edu>
Date: Sat, 04 Nov 2000 16:36:07 -0500
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT sources DOT redhat DOT com
Subject: Building C++ DLLs

Is it possible to build C++ DLL's using 'c++ -shared' (that is, ld
--shared) instead of dllwrap?

I'm running into two problems (experimenting with Mumit's dll-helpers)

First,

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++ -shared -Wl,--export-all-symbols -Wl,--output-def=cxxdll.def \
  -Wl,--out-implib=libcxxdll.a -Wl,--enable-auto-image-base \
  -o cxxdll.dll dllclass.o dllexterns.o
Cannot export _bss_end__: symbol not defined
Cannot export _bss_start__: symbol not defined
Cannot export _data_end__: symbol not defined
Cannot export _data_start__: symbol not defined
Creating library file: libcxxdll.a
collect2: ld returned 1 exit status
make: *** [cxxdll.dll] Error 1

Why is ld trying to export "_bss_end__" and friends? Those symbols are
not referenced anywhere by the source code.

So, try again.  Take the generated .def file from the previous failure,
and edit it by hand to remove "_bss_end__" and friends. Second problem:

c++ -shared \
  -Wl,--out-implib=libcxxdll.a -Wl,--enable-auto-image-base \
  -o cxxdll.dll cxxdll.def dllclass.o dllexterns.o

That works fine! But....try to compile the application that uses the
dll:

c++ -c -I. -g  -o usedll.o usedll.cc
c++ -o usedll.exe -g   usedll.o -L./ -lcxxdll
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-3/libgcc.a(tinfo.o): In function
`_rtti_class':
/cygnus/netrel/src/gcc-2.95.2-3/gcc/cp/tinfo.cc(.text+0x60): multiple
definition of `__rtti_class'
.//libcxxdll.a(d000064.o)(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [usedll.exe] Error 1

So, I do 'nm -a libcxxdll.a | grep rtti' and get:

00000000 I __imp____throw_type_match_rtti
00000000 I __imp____rtti_user
00000000 I __imp____rtti_si
00000000 T ___rtti_ptr
00000000 I __imp____rtti_ptr
00000000 T ___rtti_ptmf
00000000 I __imp____rtti_ptmf
00000000 T ___rtti_ptmd
00000000 I __imp____rtti_ptmd
00000000 T ___rtti_func
00000000 I __imp____rtti_func
00000000 T ___rtti_class
00000000 I __imp____rtti_class
00000000 T ___rtti_attr
00000000 I __imp____rtti_attr
00000000 T ___rtti_array
00000000 I __imp____rtti_array

Note that the importlib generated using the following command:

dllwrap --implib libcxxdll.a.wrap --driver-name c++ -o cxxdll.dll
cxxdll.def dllclass.o dllexterns.o

does not contain any rtti stuff (also, it seems to ignore cxxdll.def and
generate its own behind the scenes) and allows successfully link/usage
of the dll.

'nm -a libcxxdll.a.wrap | grep rtti' ---> no output

How can I generate a C++ DLL using c++ -shared (ld --shared) without
hand-editing a def file, and avoid this rtti garbage...(what is that,
anyway?)

Help...

--Chuck

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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