This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Initialisation with data from dll-libraries


JÃrgen Steensgaard-Madsen wrote:
Larry Hall (Cygwin <reply-to-list-only-lh <at> cygwin.com> writes:

JÃrgen Steensgaard-Madsen wrote:
Asking for help.
You haven't said where the dispatch table is or how it is supposed to filled
in.

First of all, thanks for reacting so promptly.


The dispatch table is an array of pointers in a C-program file to be linked
against the libraries. Initialised is expressed as a usual array declaration
initialised with individual entries given as


&some_function

where some_function is declared as extern in the same file.  This methods works
nicely with static linkage, and also with dynamic linkage on a Linux box.

Windows DLLs don't work the same as shared objects. If you want to call functions in a particular DLL, you can link your program against an import library for the DLL which contains the functions you'll be using. The import library provides the stubs for the functions that allow your program to link. At run-time, they ferry your calls across to the DLL implementation. If you don't want this, you can use dlopen and dlsym to programmatically load the DLL with the functions you want to call and get the function pointers. You may be able to adapt the former approach to your existing code with few changes. If that sounds preferable to you, I suggest you read up on Windows DLLs, importing/exporting functions, and import libraries. If you'd prefer the latter route, which is completely portable to Unix/Linux once you've made the initial code changes, I'd recommend reading up on dlopen and dlsym. In either case, neither of these subjects is Cygwin-specific so further discussion of these general areas are really off-topic for this list.


-- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]