mingw-cross-env-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-cross-env-list] MXE: How to build a self-sufficient DLL that


From: Nikos Chantziaras
Subject: Re: [Mingw-cross-env-list] MXE: How to build a self-sufficient DLL that statically includes other libraries?
Date: Tue, 24 Mar 2015 16:28:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

On 24/03/15 12:51, Matthias Geier wrote:
[...]
This makes a lot of sense in general, but I have a specific case where
I would like to mix static and shared libraries.
I would like to create a DLL for libsndfile, which should statically
include all dependencies (libFLAC, libogg, libvorbis, ...).

Build against a static MXE, but outside of MXE. That's how I create my self-containted :-)

That means, build everything libsndfile needs in MXE. Statically. But *don't* build libsndfile itself. Then, build it outside of MXE with something like the below. It also applies the MXE-specific patch and rebuilds the configure script for that patch to take effect.

(I assume here that you installed MXE in ~/opt/mxe; adjust the path below according to your MXE directory.)


  cd /tmp
  tar xf libsndfile-1.0.25.tar.gz
  cd libsndfile-1.0.25
  patch -p1 < ~/opt/mxe/src/libsndfile-1-fixes.patch
  autoreconf -fi -IM4
./configure --host=i686-w64-mingw32.static --enable-shared --disable-static --disable-sqlite --disable-octave --disable-alsa
  make -j4


This will produce a dll somewhere. Find it with:


  find . -iname "*.dll"


That dll should contain everything it needs to run on its own.

The above assumes you're on latest git master of MXE. For the old "stable" MXE, you need to adjust the --host accordingly.

Note though: this method can be problematic with C++ exception handling, since each DLL you produce contains a static copy of libgcc. If you have several DLLs that are built that way, then each one contains its own libgcc. The result of that is that exceptions might not propagate correctly. I think this only applies when the DLL is used by an *.exe or another dll that is written in C++, but I'm not sure.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]