delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/08/28/05:41:03

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <41305323.8050009@x-ray.at>
Date: Sat, 28 Aug 2004 11:40:51 +0200
From: Reini Urban <rurban AT x-ray DOT at>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.8a2) Gecko/20040714
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: questions about DLL's: .a, .def, and .dll
References: <loom DOT 20040827T173827-426 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0408271423560 DOT 6181 AT slinky DOT cs DOT nyu DOT edu> <loom DOT 20040827T221407-94 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0408271642080 DOT 9041 AT slinky DOT cs DOT nyu DOT edu> <loom DOT 20040827T230845-999 AT post DOT gmane DOT org>
In-Reply-To: <loom.20040827T230845-999@post.gmane.org>
X-IsSubscribed: yes

Oliver schrieb:
>>Secondly, the resultant DLL will be linkable from a VC++ program, but the
>>C++ functions in it will not be accessible from code compiled with VC++.
> 
> Of course, the usual c++ name mangling incompatibilities. 

And there comes the .def file to help.
You can define your needed aliases (mangled names for the target linker) 
there also.

Then you only have the other more serious C++ problems remaining:
(From the section "Why I didn't become a C++ programmer")

   different global initialization (can be overcome)

   standard library issues esp. the runtimes are mutually exclusive,
      also newlib is different to the msvc libraries in certain aspects.

   incompatible run-time issues (mostly memory management) across the 
g++/vc objects
      implicit new/delete esp. with c++, with incompatible issues
      e.g. MSVC operator new(size_t) behaves like new(size_t, 
nothrow_t&) => 0 instead of calling bad_alloc()
      The C++ libs prefer to malloc their own objects, which is a 
serious C++ design problem, since the internal memory management is 
being left to the implementor. Other run-time issues (RTTI, exceptions, 
... also of course). So libraries which leave some aspects (e.g. memory 
management) to their runtime, locking out competing products on the 
binary level.
Standardization was very implementor friendly then. And it was not 
Microsoft.
       The C API is designed to malloc it in the caller. Certain gcc 
libs wanted to be cleverer that times (the notorious x... funcs for the 
lazy). Thanksfully it's better now.)

   alignment (a typical library problem. can be easily overcome in the 
caller.)

   vtable structure and handling, inheritance (can be overcome, since 
g++ understands the msvc object layout now)

   exceptions (esp. across the library border)

All this makes it e.g. impossible to extend c++ objects at run-time, as 
any other "better" language can do. Then came COM.

FAQs:
   "Why can't g++ code link with code from other C++ compilers?"
http://docs.freebsd.org/info/g++FAQ/g++FAQ.info.problems_linking_with_other_libraries.html

   "Can I mix objects compiled with msvc++ and gcc?"
   http://www.cygwin.com/faq/faq_toc.html#TOC117
   (which only mentions the mangling problems, not the other)

   "Can I link with both MSVCRT*.DLL and cygwin1.dll?"
   http://www.cygwin.com/faq/faq_3.html#SEC95

   "How do I link against a `.lib' file?"
   http://www.cygwin.com/faq/faq_3.html#SEC100

  "How can an MSVC program call a MinGW DLL, and vice versa?"
   http://www.mingw.org/mingwfaq.shtml#faq-msvcdll
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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