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

Author Topic: SFML+CLION +CMAKE (Windows10) configuration  (Read 15475 times)

0 Members and 1 Guest are viewing this topic.

DiverDante

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #15 on: August 29, 2017, 11:22:21 am »
Hi again,
i edit the target link as suggested (both ways to be sure) but i still have the undefined reference errors

cmake_minimum_required(VERSION 3.7)
project(SFMLprova1)

set(CMAKE_CXX_STANDARD 11)


set(SFML_ROOT "C:/Code/Librerie/SFML-2.4.2")

set(CMAKE_MODULE_PATH "C:/Code/Librerie/SFML-2.4.2/cmake/Modules" ${CMAKE_MODULE_PATH})


find_package(SFML COMPONENTS network audio graphics window system REQUIRED)
include_directories(${SFML_INCLUDE_DIR})

set(SOURCE_FILES main.cpp)
add_executable(SFMLprova1 ${SOURCE_FILES})
target_link_libraries(SFMLprova1 ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})



"C:\Users\Ludovico\AppData\Roaming\JetBrains\CLion 2017.1.3\bin\cmake\bin\cmake.exe" --build C:\Users\Ludovico\CLionProjects\SFMLprova1\cmake-build-debug --target SFMLprova1 -- -j 4
[ 50%] Linking CXX executable SFMLprova1.exe
CMakeFiles\SFMLprova1.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:5: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:5: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:6: undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:7: undefined reference to `_imp___ZN2sf5Color5GreenE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:7: undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:9: undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:11: undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:13: undefined reference to `_imp___ZN2sf6Window5closeEv'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:16: undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:16: undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:17: undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:17: undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:18: undefined reference to `_imp___ZN2sf6Window7displayEv'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
C:/Users/Ludovico/CLionProjects/SFMLprova1/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
CMakeFiles\SFMLprova1.dir/objects.a(main.cpp.obj): In function `ZN2sf11CircleShapeD1Ev':
C:/Code/Librerie/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
C:/Code/Librerie/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
C:/Code/Librerie/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\SFMLprova1.dir\build.make:101: recipe for target 'SFMLprova1.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/SFMLprova1.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/SFMLprova1.dir/rule' failed
mingw32-make.exe[3]: *** [SFMLprova1.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/SFMLprova1.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/SFMLprova1.dir/rule] Error 2
mingw32-make.exe: *** [SFMLprova1] Error 2
Makefile:117: recipe for target 'SFMLprova1' failed

DiverDante

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #16 on: August 30, 2017, 10:03:16 am »
I unistalled and istalled again 32bit v of sfml and using same cmake list and same main I got this

C:\Users\Ludovico\CLionProjects\SFMLprova1\cmake-build-debug\SFMLprova1.exe

Process finished with exit code -1073741515 (0xC0000135)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #17 on: August 30, 2017, 01:11:27 pm »
Thst usually means that the application is missing a DLL. Make sure you provide the runtime and SFML DLLs.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DiverDante

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #18 on: September 08, 2017, 02:59:14 pm »
Hi again,
maybe i solve the problem but i don't think is a complete solution:
i modified the PATH in the path variables, and then the examples in the sfml libraries started to work, but my project still failed to run, returning the same error about the dll.
After many attempts, i just copied all .dll in the Cmakefiles directory and this seems to have bypassed the problem.

cmake_minimum_required(VERSION 3.7)
project(SFMLtest1)
set(SFML_ROOT "C:/Librerie/SFML-2.4.2")
#set(SFML_STATIC_LIBRARIES TRUE)
set(CMAKE_MODULE_PATH "C:/Librerie/SFML-2.4.2/cmake/Modules")
find_package(SFML 2 COMPONENTS REQUIRED system window graphics network audio)
include_directories(${SFML_INCLUDE_DIR})

set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(SFMLtest1 ${SOURCE_FILES})

target_link_libraries(SFMLtest1 ${SFML_LIBRARIES} )
 

#include <SFML/Graphics.hpp>
#include "config.h"
int main() {
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }
    return 0;
}
 



DiverDante

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #19 on: September 09, 2017, 09:47:46 am »
There is a better solution? Maybe that allows to use Sfml in any projects without copying everytime the dll?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: SFML+CLION +CMAKE (Windows10) configuration
« Reply #20 on: September 09, 2017, 01:34:17 pm »
One could add the directory with the DLLs to PATH, but this can also backfire, as some application may require a different SFML version and use the one in PATH causing a conflict.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything