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

Author Topic: Binary still asks for freetype and libjpeg DLLs even when using SFML statically  (Read 2454 times)

0 Members and 1 Guest are viewing this topic.

AnnoyingHamster

  • Newbie
  • *
  • Posts: 1
    • View Profile
Hi!

I am trying to compile my project from a Linux system and get a Windows (32 bit) executable. I'd like this executable to be fully standalone and not use any DLL file.

I installed the mingw32 version of SFML along with all its mingw32 dependencies from my distribution (archlinux) packages, and I compiled SFML statically (setting BUILD_SHARED_LIBS to false and SFML_USE_STATIC_STD_LIBS to true).

I'm able to generate the executable but when I try to launch it, it complains about missing DLLs which seem to be related to SFML (which should not happen with static linking, right?).

My compilation options (set in my CMake file) are as follow :

-DSFML_STATIC -static-libgcc -static-libstdc++ -lsfml-system-s -lsfml-window-s -lsfml-graphics-s -lboost_serialization-mt -std=c++11

Here's the output when launching the executable with wine :

err:module:import_dll Library libfreetype-6.dll (which is needed by L"Z:\\home\\aniwey\\progg\\zorro\\bin\\win32.exe") not found
err:module:import_dll Library libjpeg-62.dll (which is needed by L"Z:\\home\\aniwey\\progg\\zorro\\bin\\win32.exe") not found
err:module:import_dll Library libwinpthread-1.dll (which is needed by L"Z:\\home\\aniwey\\progg\\zorro\\bin\\win32.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\aniwey\\progg\\zorro\\bin\\win32.exe" failed, status c0000135

(I think pthread is required because of boost_serialization, but libfreetype and libjpeg must be SFML-related...)

I thought adding
-static
to the compilation options would help, but it doesn't seem to do anything :(

If it helps, here are the toolchain file I use : http://pastebin.com/tDxm4UE0, and the CMakeLists.txt file : http://pastebin.com/MmtJms0T

(compilation options are set in the toolchain file and used in the other one)

I feel like I'm missing something...

Thanks!



EDIT : I tried to modify the find_sfml_dependency macro in the FindSFML.cmake module to print the name of the libraries found. It looks like this :

    macro(find_sfml_dependency output friendlyname)
        find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib)
        message(${${output}}) # <---- I just added this line
        if(${${output}} STREQUAL "${output}-NOTFOUND")
            unset(output)
            set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
        endif()
    endmacro()

And the output is :

/usr/i686-w64-mingw32/lib/libfreetype.dll.a
/usr/i686-w64-mingw32/lib/libglew.a
/usr/i686-w64-mingw32/lib/libjpeg.dll.a
/usr/i686-w64-mingw32/lib/libopenal32.a
/usr/i686-w64-mingw32/lib/libsndfile.dll.a

Is that normal that some of the libraries end with .dll.a and not just .a? Knowing that I apparently have both .dll.a and .a on my system :

/home/ann> ls /usr/i686-w64-mingw32/lib/libfreetype* /usr/i686-w64-mingw32/lib/libjpeg*
/usr/i686-w64-mingw32/lib/libfreetype.a  /usr/i686-w64-mingw32/lib/libfreetype.dll.a  /usr/i686-w64-mingw32/lib/libjpeg.a  /usr/i686-w64-mingw32/lib/libjpeg.dll.a




EDIT : Well, I "fixed" the problem by renaming all the .dll.a files so that CMake wouldn't find them :

/usr/i686-w64-mingw32/lib> mv libjpeg.dll.a libjpeg.dll.a.save
/usr/i686-w64-mingw32/lib> mv libfreetype.dll.a libfreetype.dll.a.save
/usr/i686-w64-mingw32/lib> mv libsndfile.dll.a libsndfile.dll.a.save
/usr/i686-w64-mingw32/lib> mv libbz2.dll.a libbz2.dll.a.save
/usr/i686-w64-mingw32/lib> mv libpthread.dll.a libpthread.dll.a.save

But of course that's incredibly ugly : is there any way to force FindSFML.cmake to use the static libraries? ...
« Last Edit: March 08, 2015, 12:37:33 pm by AnnoyingHamster »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Where are you linking freetype, jpeg, etc.? (you have to when statically linking)
http://www.sfml-dev.org/faq.php#build-link-static
It's easy to miss if you only read the "sfml & linux" tutorial. :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Creating a standalone application is not supported by SFML due to the licensing of OpenAL and libsndfile.

Personally I can't recommend cross-compilation since in most cases will cause you more trouble than installing a VM and directly build on Windows.

And at last, if you start modifying the CMake scripts, you'll largely be on your own. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Quote
Creating a standalone application is not supported by SFML due to the licensing of OpenAL and libsndfile.
It is if the application code is under a LGPL compatible license.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
That's why I said SFML doesn't support it which implies that it still might be possible, but we don't provide the facilities to make it happen. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/