questions about DLL's: .a, .def, and .dll

Reini Urban rurban@x-ray.at
Sat Aug 28 12:31:00 GMT 2004


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/



More information about the Cygwin mailing list