MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Threaded Mode Threaded  

Pages: 1

Bryan Ischo
MAME Fan
Reged: 03/28/10
Posts: 358
Send PM


For Windows Developers: some questions
#265865 - 10/07/11 06:24 PM


Hello there. I am very uninformed when it comes to Microsoft Windows programming. It's not that hard to make portable code, so compiling my code is not the hard part; the hard part is figuring out exactly what developers expect from a binary version of a library.

On Linux (my main development platform), I can simply build a static library and shared library and package it along with the headers and that's all I need.

But on Windows I am not sure exactly what I would need to produce for a binary version of a library meant to be picked up and used by other developers. I have seen Windows libraries distributed with .dll files in a 'bin' directory, or sometimes in a 'lib' directory. Sometimes I see files that end in .def as well.

Can someone who is a Windows programmer tell me exactly what they would expect to find in a .zip file that contained a compiled C++ library? Just for reference, I expect at a minimum to provide: libmame.a, libmame.dll, libmame.h ...

I have actually read about Windows .dlls and such so I know something of how shared libraries work on Windows but I can't tell exactly what the conventions are for distributing them.

Will a .dll compiled by MingW be sufficient for linking by any Windows compiler? Are there any special caveats I need to pay attention to? The GNU toolchain doesn't seem to require all of the 'dllexport/dllimport' baloney that I often see in Windows code - is that stuff needed for other Windows compilers, or is it just optional?

I hope to be releasing some code and a library soon and the Linux version has been ready since forever, but I just finished putting the finishing Windows porting touches on it and now I have no idea how to actually make a distributable version for Windows, so any hints at all will be most helpful.

Thanks!



sz72
MAME Fan
Reged: 08/20/07
Posts: 78
Send PM


Re: For Windows Developers: some questions new [Re: Bryan Ischo]
#265993 - 10/09/11 09:39 PM


> Hello there. I am very uninformed when it comes to Microsoft Windows programming.
> It's not that hard to make portable code, so compiling my code is not the hard part;
> the hard part is figuring out exactly what developers expect from a binary version of
> a library.
>
> On Linux (my main development platform), I can simply build a static library and
> shared library and package it along with the headers and that's all I need.
>
> But on Windows I am not sure exactly what I would need to produce for a binary
> version of a library meant to be picked up and used by other developers. I have seen
> Windows libraries distributed with .dll files in a 'bin' directory, or sometimes in a
> 'lib' directory. Sometimes I see files that end in .def as well.
>
> Can someone who is a Windows programmer tell me exactly what they would expect to
> find in a .zip file that contained a compiled C++ library? Just for reference, I
> expect at a minimum to provide: libmame.a, libmame.dll, libmame.h ...
>
> I have actually read about Windows .dlls and such so I know something of how shared
> libraries work on Windows but I can't tell exactly what the conventions are for
> distributing them.
>
> Will a .dll compiled by MingW be sufficient for linking by any Windows compiler? Are
> there any special caveats I need to pay attention to? The GNU toolchain doesn't seem
> to require all of the 'dllexport/dllimport' baloney that I often see in Windows code
> - is that stuff needed for other Windows compilers, or is it just optional?
>
> I hope to be releasing some code and a library soon and the Linux version has been
> ready since forever, but I just finished putting the finishing Windows porting
> touches on it and now I have no idea how to actually make a distributable version for
> Windows, so any hints at all will be most helpful.
>
> Thanks!

The minimum is the dll and the corresponding import library.
But the import library is compiler specific (dll must not be).
So you can include a .def file, a text file that can be used to create an import library for the specific compiler of the user.
There are more or less automatic ways to create a def file and an import library if you have only the dll.



Bryan Ischo
MAME Fan
Reged: 03/28/10
Posts: 358
Send PM


Re: For Windows Developers: some questions new [Re: sz72]
#266015 - 10/10/11 06:40 AM


Thank you very much for the reply. That is exactly the information I needed. So it's .h, .dll. and .def as the three files that developers will need; I will make sure that I distribute these at a minimum. Fortunately my library uses only C functions as its API so I won't have to worry about name mangling, which I understand works differently for different compilers.

I don't think I'll distribute a static .a library ... nobody would miss that, right?



lharms
MAME Fan
Reged: 01/07/06
Posts: 908
Send PM


Re: For Windows Developers: some questions new [Re: Bryan Ischo]
#266585 - 10/17/11 01:46 AM


A .lib is nice. But like sz72 said not required (as there are ways to make it).

Most libraries I have seen have these three .h, .lib, and .dll.

As for name mangling if you are using any sort of C++ and a MS compiler you will end up with it (by default). There are ways to turn it off. Typically you either mark your export points as "C" or write some sort of trampoline layer.

The MS compiler will create a .lib for you that you can include into other projects. If you were to crack it open you would see some asm that does the heavy lifting of mapping functions and LoadLibrary/GetProcAddress. Hiding the details of that by making a nice abstraction layer for you.

Edited by lharms (10/17/11 03:29 AM)


Pages: 1

MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Pi 
0 registered and 49 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2668