Hello,
Perhaps it's just me, but I haven't succeeded to link SFML statically on g++ with MinGW. I use the following CMake script and try to compile the SFML pong example:
cmake_minimum_required(VERSION 2.8)
project(PongExperiment)
set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 COMPONENTS system window graphics audio)
message(STATUS "Libraries [${SFML_LIBRARIES}]")
include_directories(${SFML_INCLUDE_DIR})
add_executable(PongExperiment Pong.cpp)
add_definitions(-DSFML_STATIC)
target_link_libraries(PongExperiment ${SFML_LIBRARIES})
if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(PongExperiment PROPERTIES LINK_FLAGS "-static-libgcc")
endif()
install(TARGETS PongExperiment RUNTIME DESTINATION .)
While running CMake, I get the output of the following form, so the libraries have been chosen correctly.
debug;<PATH>/libsfml-system-s-d.a;optimized;<PATH>/libsfml-system-s.a;
When I execute Make, I get loads of undefined symbols, here an example:
C:\Program Files\C++ Libraries\SFML\MinGW\lib\libsfml-window-s.a(Window.cpp.obj)
:Window.cpp:(.text+0x445): undefined reference to `sf::Err()'
The same CMake script works fine with Visual Studio 2010 as generator. Do you know what might be wrong?