Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Alejandro Lopez-Valencia Subject: Re: Creating DLL's for use with MSVC Date: Wed, 10 Mar 2004 06:44:01 -0500 Organization: Casa de Cuckoo Lines: 62 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org Keywords: No keywords can be a good thing. X-Gmane-NNTP-Posting-Host: 200.119.72.113 X-Archive: encrypt Mail-Copies-To: never X-Newsreader: Do you care? X-UserAgent: Does it really matter? X-Newsreader: Forte Agent 2.0/32.646 Reply-To: cygwin AT cygwin DOT com On Wed, 10 Mar 2004 08:59:26 +0100, Niklas Wallin wrote in : >We are currently porting a linux C++ project to windows. The project >consists of several dll's (or .so's). To recreate those dll's in >Windows it seems like you have to add a lot of __cdecls definitions or >use a definitions file. Neither method is appealing to us. So, I read >somewhere that Cygwin might do the trick by exporting all symbols. So, >I started to compile dll's in cygwin: > >c++ -shared -mno-cygwin -o mydll.dll mydll.cpp \ > -Wl, --out-implib=mydll.lib > -W1,--output-def=mydll.def > -W1,--export-all-symbols > 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 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: 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 you are using this within a Makefile, you should rather input the object files. Like this: cc++ -shared -mno-cygwin $(CXXFLAGS) -o mydll.dll \ -Wl,--out-implib=mydll.lib \ -Wl,--compat-implib \ -Wl,--add-stdcall-alias \ -Wl,--enable-stdcall-fixup \ -Wl,--enable-auto-import \ -Wl,--enable-auto-image-base \ -Wl,--whole-archive \ $(MY_DLL_OBJECT_FILES_LIST) \ my_dll_symbols_export_list.def \ -Wl,--no-whole-archive \ $(ANY_LIBRARIES_THE_DLL_SHOULD_AUTO_LOAD) See GNU GCC and GNU binutils' documentation for an explanation. (This, btw, should go in the FAQ, consider it a contribution). -- 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/