[Liboil] build error

Stephane Fillod f8cfe at free.fr
Wed Nov 2 13:14:51 PST 2005

On Wed, Nov 02, 2005 at 11:36:44AM -0800, David Schleef wrote:
> On Wed, Nov 02, 2005 at 10:23:22AM +0100, Sébastien Moutte wrote:
> > Thanks, it builds now from cvs since David has applied your patch.
> > I built it with a fresh install of cygwin+gcc-3.4.4-1+autoconf 2.59 + 
> > automake 1.9.6.
> > But it doesn't build what i need :) i need a windows DLL and an export 
> > library file to build project like gstreamer with visual studio.
> > cygwin builds executables linked on the linux API emulation layer 
> > library cygwin1.dll.
> > So cygwin isn't the good way for me.

FYI, you can produce cygwin-free DLLs from Cygwin. Simply pass
"-mno-cygwin" to gcc and g++ (as in CC, CXX). But the pure MinGW way
is IMHO better for the current case.

> > I'm now trying with MinGW, it builds fine and generates executable which 
> > links on windows C run-time but it generates unix libraries (.a/.la).
> > What's the way to generate a liboil windows library with MinGW ?

The .la is normal output by libtool. You may ignore it for VisualC++.
The straight .a is static(non-shared) archive for MinGW use, useless
to VC++. You should have obtained a .dll when compiling using MinGW.
If not, make sure you pass --endable-shared to configure (and
--disable-static since .a are of no use). Now, you may notice a .dll.a
file. This is an import library (static) for the shared library (.dll).
Since it's MinGW stuff, once again, forget about it.
What you want for VC++ is a bare .DLL and a .LIB. The .DLL you have it
already, generated by MinGW, and compatible with VC++ as long as only
pure C symbols are exported (C++ ABIs of MinGW and VC++ do not mate).

Here's how to get the .LIB out of the .DLL.
When compiling under MinGW, add "-Wl,--output-def,liboil.def -Wl,--add-stdcall-alias"
to liboil_ at LIBOIL_MAJORMINOR@_la_LDFLAGS. In some other project 
I maintain (http://hamlib.org), I have the optional flags added
automagically in configure.ac:

  case "$host_os" in
	mingw* | pw32* | cygwin*)
	  WINLDFLAGS="-Wl,--output-def,liboil.def -Wl,--add-stdcall-alias"

To create a MSVC-compatible interface .LIB library, do the following in a
Windows command window from the directory where you put all that stuff:

	lib.exe /def:liboil.def /machine:IX86 /name:liboil-x-y

This will create liboil.lib and liboil.exp (liboil-x-y is the optional dll name).

REM: Using the (free) Microsoft Visual C++ Toolkit 2003, replace
the "lib.exe" command by "link.exe /lib". All this can be done under
Linux. The MS Toolkit is free (as in beer), and runs well under Wine.
You understood already, I seldomly reboot under Windows, maybe once
or too times a year. Yet from the same source tree (thanks VPATH!),
binary are generated for many archs.

Liboil.lib and the .h includes can now be used within any MSVC build,
should you have such a funny idea :-)

> > Is there already binary packages of liboil for windows ?
> I just cross-compiled for i586-mingw32msvc, and it produced a DLL
> and supporting files, so I'm kind of confused.  There's a possibility
> that your libtool is a bit old and doesn't support building DLLs on
> the mingw32msvc target, or that the compiler doesn't want to build
> them for some reason.
> Could you try compiling this snapshot:
>   http://home.schleef.org/~ds/liboil-
> It contains the same libtool that works here, so if that doesn't
> work, there's something wrong with your setup.

That'd be nice Dave to generate DLL/LIB packages for Windows users.
Freedom through obsolescence, eh! This would help making liboil even
more popular.


More information about the Liboil mailing list