building a shared library (dll) for win32

13 views
Skip to first unread message

bob.cook

unread,
Mar 27, 2009, 12:45:27 AM3/27/09
to spserver
I have a question about the Win32 port. When using an LGPL-licensed
library there is a requirement for a run-time linkage, which requires
a shared object file. The Linux build does this by default but the
Win32 port builds a shared library. My question is about whether you
plan to support this or not.

The Microsoft compiler requires one of two mechanisms to make symbols
externally visible from a DLL: (1) put the desired external symbols
into a .def file, or (2) use the __declspec(dllexport) language
extension on class or function names. The first mechanism is rather
inconvenient especially for C++ due to the name mangling. The second
method is nicer but requires injecting extra compiler-specific code
into the source.

Typical projects implement the second method using a macro that is
only set to something meaningful when compiling with the Microsoft
compiler.

By the way there is a __declspec(dllimport) directive required for the
header when trying to link against the resulting DLL. This is
typically handled by using a different value for the macro described
above.

I can provide some example code if that is useful. I can also make the
required source code changes and submit them back to you if that would
be more helpful.

Bob Cook

lau stephen

unread,
Mar 27, 2009, 1:36:22 AM3/27/09
to spse...@googlegroups.com
Hi, bob

Thanks for your suggestion.

If the spserver use the license like the FLTK, it will avoid to worry
about the static linking.
http://www.fltk.org/COPYING.php

If you can provide an example or a patch for building a dll, it will
be appreciatived.

2009/3/27 bob.cook <bob....@gmail.com>:

Bob Cook

unread,
Mar 27, 2009, 10:22:00 AM3/27/09
to spse...@googlegroups.com
Hi,

Yes I agree the FLTK license would eliminate the requirement to ship the
spserver library as a DLL. Are you considering to switch to that license
rather than the LGPL? That would be good news.

I will put together a small example of what is required and send it to
you later today. If you like it I'd be happy to supply a patch for the
entire project.

Bob Cook

stephen.nil

unread,
Mar 28, 2009, 12:02:40 AM3/28/09
to spserver
Hi,

I have add some exceptions like FLTK to the COPYING.

Bob Cook

unread,
Mar 28, 2009, 1:58:46 PM3/28/09
to spse...@googlegroups.com
Hi,

I've uploaded an example to the Google Groups files section. It contains
a very tiny example project showing how to build and use c++ classes in
a dll. The real-world is much more complicated of course but this should
give anyone who is interested a basic idea what is needed.

I still believe static libraries are going to be a better approach, and
now that the license has been revised to allow that my motivation to
make the win32 port compile as a dll is very low, so I probably won't do
the work unless someone else would really value it.

Bob Cook

stephen.nil

unread,
Mar 29, 2009, 7:46:27 AM3/29/09
to spserver
Hi, Bob

Thanks for your example.

Reply all
Reply to author
Forward
0 new messages