1
General / Binary still asks for freetype and libjpeg DLLs even when using SFML statically
« on: March 08, 2015, 05:35:30 am »
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 :
Here's the output when launching the executable with wine :
(I think pthread is required because of boost_serialization, but libfreetype and libjpeg must be SFML-related...)
I thought adding
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 :
And the output is :
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 :
EDIT : Well, I "fixed" the problem by renaming all the .dll.a files so that CMake wouldn't find them :
But of course that's incredibly ugly : is there any way to force FindSFML.cmake to use the static libraries? ...
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
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()
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
/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
/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
/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? ...