I apologize for bothering you all, but I have a slight problem compiling with cmake.
I have a CMakeLists.txt file that I use to create a test executable and a shared library. They both have a dependency on another library (SFML).
I am using cmake in a window with MinGW.
I know that the name lib I create is confused with sfml, but it must be an SFML wrapper, so I could not find a better name!
Here is CMakeLists.txt
cmake_minimum_required(VERSION 2.6) project(projectName) set(EXECUTABLE_NAME testSFML) set(LIBRARY_NAME SFMLwindow) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin/) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include / ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/) file( GLOB_RECURSE SRC_FILES src/* ) file( GLOB_RECURSE INCLUDE_FILES include/* ) add_executable( ${EXECUTABLE_NAME} main.cpp ${SRC_FILES} ${INCLUDE_FILES} ) target_link_libraries( ${EXECUTABLE_NAME} sfml-main sfml-system sfml-window ) add_library( ${LIBRARY_NAME} SHARED ${SRC_FILES} )
And what I get in the terminal:
"C:\MinGW\bin\mingw32-make.exe" -- Configuring done -- Generating done -- Build files have been written to: C:/Users/iksemel/docs/WorkBench/programming/projets/TestSFML/cmake Linking CXX shared library libSFMLwindow.dll Creating library file: libSFMLwindow.dll.a CMakeFiles\SFMLwindow.dir/objects.a(SFMLWindow.cpp.obj):SFMLWindow.cpp:(.text+0x59):undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj' CMakeFiles\SFMLwindow.dir/objects.a(SFMLWindow.cpp.obj):SFMLWindow.cpp:(.text+0xda): undefined reference to `_imp___ZN2sf6WindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE' CMakeFiles\SFMLwindow.dir/objects.a(SFMLWindow.cpp.obj):SFMLWindow.cpp:(.text+0x163): undefined reference to `_imp___ZN2sf6Window5closeEv' CMakeFiles\SFMLwindow.dir/objects.a(SFMLWindow.cpp.obj):SFMLWindow.cpp:(.text+0x1bd): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE' CMakeFiles\SFMLwindow.dir/objects.a(SFMLWindow.cpp.obj):SFMLWindow.cpp:(.text+0x1d8): undefined reference to `_imp___ZN2sf6Window7displayEv' collect2: ld a retourné 1 code d'état d'exécution mingw32-make.exe[2]: *** [libSFMLwindow.dll] Error 1 mingw32-make.exe[1]: *** [CMakeFiles/SFMLwindow.dir/all] Error 2 mingw32-make.exe: *** [all] Error 2
If someone tells me what is going on, I will be very grateful!
Cuthalion
source share