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 Mime-Version: 1.0 (Apple Message framework v612) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Niklas Wallin 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/