gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: Re: Probably the right place for this Windows question.
From: Byron A Jeff
Date: Wed, 30 Apr 2003 19:37:38 -0400

On Wed, Apr 30, 2003 at 06:25:04PM -0400, Charles Lepple wrote:
> 
> Aaron said:
> > On Wed, 30 Apr 2003 16:23:35 -0400 (EDT)
> > byron@cc.gatech.edu (Byron A Jeff) wrote:
> >
> >> As I pointed out eariler, I found the answer. It's in the io.cpp and
> >> io.h files included with the package. It shows LoadLibrary,
> >> FreeLibrary, and  GetProcAddress. That's what I needed to know. It
> >> looks like I can simply  incorporate those files directly into
> >> picprg2.3 and use the calls to control the port.
> >
> > I think that you need to generate a .def file also, or something
> > similar. It's been a while since I played with dll's, but the mingw faq
> > mentions how to use DLLs, and how to pull the neccesary info out of the
> > DLL in order to use it. I skimmed over it a couple days ago, but wasn't
> > paying much attention unfortunately.

I read it a couple of times. I do see that pexports and dlltool will build
an import library from a raw dll. It's making a bit more sense now.

> 
> While it's a little different than just linking a .lib/.a file, using
> LoadLibrary etc. could allow picprg to be more robust to user
> configuration problems. You can print a better error message (including
> pointers to documentation/FAQs), for instance.

Plus to be honest it makes sense to me. It's more akin to dlopen and dlsym
in the Unix shared library world.

> You could even get crazy and make an abstraction layer that would allow a
> user to use one of the several general-purpose port I/O DLLs out there.
> picprg could iterate over a list of recognized DLLs and their respective
> inb/outb function names, and pick the first one that works.

No need. My game plan is to bundle the DLL with the program. The other nice 
thing about LoadLibrary is that you can specifically pick the one in the 
current directory.

> 
> Of course, I'm not volunteering to write the patch for that functionality
> :-) but doing your own dynamic linking (on a small scale) can have some
> advantages.

I agree. BTW I'm not going to implement it either! ;-)

BAJ

gnupic@linuxhacker.org