[libvirt] Fedora MinGW - need for *.def files

Richard W.M. Jones rjones at redhat.com
Mon Nov 16 11:23:15 UTC 2009


[This is just a FYI ...]

Upstream binutils or gcc changed the default way that symbols are
exported for cross-compiled (Fedora MinGW) DLLs.  Previously all
symbols were exported.  Now they are only exported if they are
explicitly listed in a *.def file.

There are two ways that libvirt could be changed to do the right
thing here.

Either (probably simplest) add '-export-all-symbols' to the libtool
command line.  This would have to be done conditionally based on Win32
being the compilation target.

Or create a *.def file.  It looks like:

  LIBRARY libvirt.dll
  DESCRIPTION "libvirt foo blah"
  EXPORTS
  <<list of symbol names, one per line>>

  http://msdn.microsoft.com/en-us/library/d91k01sh%28VS.80%29.aspx
  http://msdn.microsoft.com/en-us/library/28d6s79h%28VS.80%29.aspx

The LIBRARY and DESCRIPTION lines are optional.

You have to add '-export-symbols libvirt.def' to the libtool command
line.  (It's not clear to me at the moment if you only do this for
Windows or if it's safe to pass this on all platforms -- the
documentation for this is very sparse).

There is a third method: you can munge all the code by adding
__declspec(dllexport) to all exported symbols in the header files,
conditionally of course.  I'm pretty sure that's the worst of all
worlds.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top




More information about the libvir-list mailing list