delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/10/08:24:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Mime-Version: 1.0 (Apple Message framework v612)
In-Reply-To: <c2mv33$u1m$1@sea.gmane.org>
References: <D9B6A11B-7268-11D8-B092-000393C92B12 AT foi DOT se> <c2mv33$u1m$1 AT sea DOT gmane DOT org>
Message-Id: <DEA1FE60-7295-11D8-B092-000393C92B12@foi.se>
From: Niklas Wallin <niklas DOT wallin AT foi DOT se>
Subject: Re: Creating DLL's for use with MSVC
Date: Wed, 10 Mar 2004 14:21:41 +0100
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

Thanks for your answer Alejandro, I still can't get it right though.

class MyClass
{
public:
   MyClass();
   ~MyClass();
   int getValue();
   void setValue(int val);
private:
    int value_;
};



> Try:
>
> cc++ -shared -mno-cygwin -o mydll.dll mydll.cpp \
> 	-Wl,--out-implib=mydll.lib \
> 	-W1,--output-def=mydll.def \
> 	-W1,--export-all-symbols \
> 	-Wl,--enable-auto-import \
> 	-Wl,--enable-auto-image-base \
> 	-Wl,--compat-implib \
> 	-Wl,--add-stdcall-alias \
> 	-Wl,--enable-stdcall-fixup
>

Ok, the .def file then looks like this:

EXPORTS
     _ZN7MyClass8getValueEv @1
     _ZN7MyClass8setValueEi @2
     _ZN7MyClassC1Ev @3
     _ZN7MyClassC2Ev @4
     _ZN7MyClassD1Ev @5
     _ZN7MyClassD2Ev @6



> Yu should recycle recycle your def file. You see, it will contain a
> lot of unnecessary symbols, so... After you have obtained a def file
> above, edit it to include only the symbols you really need exported
> and include it in your project for future use. Then you can do:
>

I guess I don't have to edit this file

> cc++ -shared -mno-cygwin -o mydll.dll mydll.cpp mydll.def \
> 	-Wl,--out-implib=mydll.lib \
> 	-Wl,--compat-implib \
> 	-Wl,--enable-auto-import \
> 	-Wl,--enable-auto-image-base \
> 	-Wl,--add-stdcall-alias \
> 	-Wl,--enable-stdcall-fixup
>
> To obtain a well behaved dll and a (probably?) usable import library.
>

If the .dll and .lib file is correct I can't tell. When I try to link 
the .lib file with an MSVC executable it still can't find the 
references. I am not sure what to expect, should the lib, def and dll 
contain Cygwin decorated symbols (which is the case now) or the MSVC 
symbols? Or do I have to add any flags to the MSVC linker (compiler) to 
solve the name differences?

/ Niklas


--
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