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 Message-ID: <43204E9E.B5C05D69@dessent.net> Date: Thu, 08 Sep 2005 07:45:50 -0700 From: Brian Dessent MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Callbacks from shared libraries compiled with cygwin References: <431FFEDC DOT 9030908 AT carmen DOT se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Michael Spicar wrote: > So I have two questions: > 1) Is it possible at all to have callbacks like this? > 2) If yes, must I have the import/export-lists? Yes, it's possible, but it's not considered great design. You have to use __declspec(export) on the symbols in the main .exe, and then produce and import library for that .exe, and then link against that import library when you link the shared library. But this will hard-code a dependence on the .exe name into the .dll, which means the .exe can never be renamed, and the dll cannot be used with any other .exe. A better alternative is to factor out the variables/functions that you want to access from both the main .exe and the .dll into another common .dll that is imported by both. Or change your API so that when main calls the function in the shared library it passes a function pointer as argument to the routine in main. 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/