Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: MinGW 32-bit package - a couple of questions and a suggestion  (Read 2947 times)

0 Members and 1 Guest are viewing this topic.

georger

  • Guest
MinGW 32-bit package - a couple of questions and a suggestion
« on: August 17, 2013, 06:02:45 pm »
Questions for Laurent:
1) What are your own steps for building openal32.dll and libsndfile-1.dll in extlibs\bin\x86?
2) Why are libOpenAL32.a and libsndfile.a in extlibs\libs-mingw\x86 named like static libraries but are actually import libraries?

Suggestion: how about an SFML-deps source package?

Now for the rationale about the questions.

PREPARING THE BUILD ENVIRONMENT
The download package "GCC 4.7 MinGW (DW2) - 32 bits" is targeted at GCC 4.7, which I unfortunately can't use because I have 2 other libraries that won't compile with it - but that do compile just fine with MinGW's pre-packaged repository packages which ship GCC 4.6.2. My environment is as vanilla as it gets:

- I installed MinGW using mingw-get-inst-20120426.exe and chose "Use pre-packaged repository catalogues 20120426" when prompted to do so during installation.
- I installed MinGW to C:\MinGW.
- I chose the following components during installation: "C Compiler", "C++ Compiler", and "MinGW Developer ToolKit".
- I added C:\MinGW\bin to my PATH environment variable, and rebooted.

I then downloaded the SFML 2.1 sources and decided to replace the bundled openal32.dll, libsndfile-1.dll, libOpenAL32.a, and libsndfile.a with my own rebuilt binaries.

BUILDING THE DEPENDENCIES
1) Get gettext-runtime_0.18.1.1-2_win32.zip, glib_2.28.8-1_win32.zip, and pkg-config_0.26-1_win32.zip from the GTK+ project and put the contents of the extracted bin folders in C:\MinGW\msys\1.0\bin.
2) Download the libsndfile dependencies (flac-1.3.0.tar.xz, libogg-1.3.1.zip, and libvorbis-1.3.3.zip) and extract them, then run MSYS and compile them:
Ogg
./configure --prefix=/mingw
make && make install

Vorbis
./configure --prefix=/mingw
make && make install

FLAC
./configure --prefix=/mingw
make && make install
3) Download libsndfile (libsndfile-1.0.25.tar.gz) and , extract it, run MSYS and compile it:
export PKG_CONFIG_PATH="/mingw/lib/pkgconfig"
./configure --enable-shared --disable-static --prefix=/mingw
make && make install

Now we have libsdnfile (and its dependencies) neatly built and ready to use in C:\MinGW\bin, C:\MinGW\include and C:\MinGW\lib. In particular we now have libsndfile-1.dll and libsndfile.dll.a.

Hmm, there's a bunch of new DLLs in C:\MinGW\bin: libogg-0.dll, libvorbis-0.dll, libvorbisfile-3.dll, libvorbisenc-2.dll, libFLAC-8.dll, libFLAC++-6.dll, and libsndfile-1.dll. Let's delete them because we don't need them (or is it) - nah, let's just move them somewhere else. We could need them in the future!

Now let's compile OpenAL32.dll.
1) Download dsound.h (I guess MinGW can't bundle it) and copy it to C:\MinGW\include.
2) Download the OpenAL Soft source code (openal-soft-1.15.1.tar.bz2) and extract it somewhere.
3) Build it with CMake GUI as usual, clicking Configure then choosing MinGW Makefiles and Use default native compilers.

Now we have OpenAL32.dll and libOpenAL32.dll.a.

Notice that we have libsndfile.dll.a and libOpenAL32.dll.a rather than libsndfile.a and libOpenAL32.a which are found in the extlibs\libs-mingw\x86 folder in SFML's source distribution - should we have compiled them as static libraries rather than DLLs? But, let's move on.

BUILDING SFML
Let's download the SFML 2.1 source package (SFML-2.1-sources.zip), extract them to C:\TEMP and build it with CMake GUI as usual, clicking Configure then choosing MinGW Makefiles and Use default native compilers.

I clicked Browse Source... and pointed it to C:/TEMP/SFML-2.1-Release
I clicked Browse Build... and pointed it to C:/TEMP/SFML-2.1-Release-build
I clicked CMAKE_INSTALL_PREFIX and pointed it to C:/TEMP/SFML-2.1-Release-dist

Replace the original OpenAL32.dll and libOpenAL32.dll.a. files in extlibs\bin\x86 with the ones you just built.
Also copy libsndfile.dll.a and libOpenAL32.dll.a to extlibs\libs-mingw\x86.

Run cmd to open a command prompt, cd to C:\TEMP\SFML-2.1-sources\SFML-2.1-Release-build, run mingw32-make - boom, it doesn't build. But that's easily fixed: just delete libOpenAL32.a and libsndfile.a in extlibs\libs-mingw\x86, then rename libsndfile.dll.a to libsndfile.a and libOpenAL32.dll.a to libOpenAL32.a, and finally try building again with mingw32-make. Success! Run mingw32-make install and take a look at C:\TEMP\SFML-2.1-sources\SFML-2.1-Release-dist after it's finished. Done! We'll copy the DLLs to C:\MinGW\bin so that they can be found by any application that needs them.

Now let's test the shiny library we just built. I compiled a little game I have that plays an .ogg file... oh no, the application refuses to run because it can't find libvorbisenc-2.dll! Luckily we didn't delete this DLL and its friends, we just moved them somewhere else. Let's put them back in C:\MinGW\bin and try again... Now my game runs AND plays the .ogg file!

THE GOTCHA
Hmm, but when I use the binary distribution I don't need libvorbisenc-2.dll (it's not even present in the ZIP).
Also, the bundled libsndfile-1.dll is noticeably bigger than the one I built myself - 2.16 vs 1.73 MB.
How come? Were libvorbisenc-2.dll and other libraries "fused" into libsndfile-1.dll as per this FAQ entry?

Sorry for the long message. I'm just curious, and would really really like to know how SFML's dependencies are built in order to build my own package.
« Last Edit: August 17, 2013, 06:10:08 pm by georger »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: MinGW 32-bit package - a couple of questions and a suggestion
« Reply #1 on: August 17, 2013, 06:10:13 pm »
Quote
1) What are your own steps for building openal32.dll and libsndfile-1.dll in extlibs\bin\x86?
I don't rebuild libsndfile, I use the precompiled Windows binaries.
I rebuild OpenAL-Soft with CMake, I don't do anything special.

Why do you want to rebuilt them? They are C libraries, and thus their DLL can be used with any compiler, and their import libraries can be used with any version of the corresponding compiler (look, there's just one version of each in extlibs).

Quote
Also, the bundled libsndfile-1.dll is noticeably bigger than the one I built myself - 2.16 vs 1.73 MB.
How come? Were libvorbisenc-2.dll and other libraries "fused" into sfml-audio-2.dll as per this FAQ entry?
Apparently it links all its dependencies statically, which explains the bigger size and the lack of extra DLLs.
Laurent Gomila - SFML developer

georger

  • Guest
Re: MinGW 32-bit package - a couple of questions and a suggestion
« Reply #2 on: August 17, 2013, 06:21:03 pm »
Why do you want to rebuilt them? They are C libraries, and thus their DLL can be used with any compiler, and their import libraries can be used with any version of the corresponding compiler (look, there's just one version of each in extlibs).
I didn't know that C libraries could be used by any compiler  :o I googled a bit about it, that is (was) something new for me - thanks for the prompt answer, and for teaching me!

Best regards,

Georger