X-Spam-Check-By: sourceware.org Message-ID: <466EC2CF.E39316C1@dessent.net> Date: Tue, 12 Jun 2007 08:59:11 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: dll link error using Cygwin gcc References: <000001c7ad08$f72b9280$e582b780$@mills AT novaspeech DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Harold Mills wrote: > I'm trying to use Cygwin's gcc to link a small test program (Hello.c) > against a commercial DLL (ibmeci.lib), the source code for which I don't > have. I followed the instructions at www.cygwin.com/cygwin-ug-net/dll.html > to try to build a Cygwin-compatible import library: > > echo EXPORTS > ibmeci.def > nm ibmeci.lib | grep ' T _' | sed 's/.* T _//' >> ibmeci.def > dlltool --def ibmeci.def --dllname ibmeci.lib --output-lib ibmeci.a This is equivalent to "cp ibmeci.lib ibmeci.a", i.e. it's wasted effort. They're the same file format. You can just use ibmeci.lib. > I get the ld error message "undefined reference to '_eciSpeakText'". The > Hello.c program calls a function 'eciSpeakText'. If you're getting undefined reference to _eciSpeakText that means the function is declared with the cdecl (default) calling convention in eci.h. However, the library probably uses stdcall since its symbols are decorated with @nn, so you need to fix the header before anything else. Both user and library must agree on calling convention as well as symbol decoration before anything will work. Usually the two go hand-in-hand, but sometimes you get oddball combinations like stdcall-without- AT nn-decoration which requires you to cook up an import lib with the appropriate aliases. Brian -- 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/