//main.cpp
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640,480,32),"Hello SFML");
sf::Font font;
font.loadFromFile("resources/fonts/Pacifico.ttf");
sf::Text text("Hello World",font,11);
text.setCharacterSize(32);
text.setPosition(window.getSize().x/2 - text.getGlobalBounds().width/2,
window.getSize().y/2 - text.getGlobalBounds().height/2);
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)) {
if(event.type == sf::Event::Closed){
window.close();
}
window.clear(sf::Color::Black);
window.draw(text);
window.display();
}
}
return 0;
}
//CMakeList.txt
cmake_minimum_required(VERSION 3.10)
# set the projectX name to the name of your project
project(sfml_clion_template-master)
set(CMAKE_CXX_STANDARD 11)
# set(SOURCE_FILES main.cpp)
add_executable(sfml_clion_template-master main.cpp)
#add_executable(Game ${SOURCE_FILES})
set(SFML_ROOT "D:/Libraries/SFML")
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES})
endif()
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\cristina\Desktop\sfml_clion_template-master\sfml_clion_template-master
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:14 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable SFML_ROOT is set to:
D:/Libraries/SFML
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found SFML 2.5.1 in D:/Libraries/SFML/include
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/cmake-build-debug
[Finished]
====================[ Build | sfml_clion_template-master | Debug ]==============
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\cristina\Desktop\sfml_clion_template-master\sfml_clion_template-master\cmake-build-debug --target sfml_clion_template-master -- -j 2
Scanning dependencies of target sfml_clion_template-master
[ 50%] Building CXX object CMakeFiles/sfml_clion_template-master.dir/main.cpp.obj
[100%] Linking CXX executable sfml_clion_template-master.exe
CMakeFiles\sfml_clion_template-master.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:6: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:6: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:6: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:8: undefined reference to `_imp___ZN2sf4FontC1Ev'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:9: undefined reference to `_imp___ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:11: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:11: undefined reference to `_imp___ZN2sf4TextC1ERKNS_6StringERKNS_4FontEj'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:12: undefined reference to `_imp___ZN2sf4Text16setCharacterSizeEj'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:14: undefined reference to `_imp___ZNK2sf12RenderWindow7getSizeEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:14: undefined reference to `_imp___ZNK2sf4Text15getGlobalBoundsEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:13: undefined reference to `_imp___ZNK2sf12RenderWindow7getSizeEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:13: undefined reference to `_imp___ZNK2sf4Text15getGlobalBoundsEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:14: undefined reference to `_imp___ZN2sf13Transformable11setPositionEff'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:17: undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:20: undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:22: undefined reference to `_imp___ZN2sf6Window5closeEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:25: undefined reference to `_imp___ZN2sf5Color5BlackE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:25: undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:26: undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:26: undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:27: undefined reference to `_imp___ZN2sf6Window7displayEv'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:8: undefined reference to `_imp___ZN2sf4FontD1Ev'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:6: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:8: undefined reference to `_imp___ZN2sf4FontD1Ev'
C:/Users/cristina/Desktop/sfml_clion_template-master/sfml_clion_template-master/main.cpp:6: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
CMakeFiles\sfml_clion_template-master.dir/objects.a(main.cpp.obj): In function `ZN2sf8DrawableD2Ev':
D:/Libraries/SFML/include/SFML/Graphics/Drawable.hpp:52: undefined reference to `_imp___ZTVN2sf8DrawableE'
CMakeFiles\sfml_clion_template-master.dir/objects.a(main.cpp.obj): In function `ZN2sf11VertexArrayD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/VertexArray.hpp:45: undefined reference to `_imp___ZTVN2sf11VertexArrayE'
CMakeFiles\sfml_clion_template-master.dir/objects.a(main.cpp.obj): In function `ZN2sf4TextD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `_imp___ZTVN2sf4TextE'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `_imp___ZTVN2sf4TextE'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `_imp___ZN2sf13TransformableD2Ev'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [sfml_clion_template-master.exe] Error 1
CMakeFiles\sfml_clion_template-master.dir\build.make:90: recipe for target 'sfml_clion_template-master.exe' failed
CMakeFiles\Makefile2:74: recipe for target 'CMakeFiles/sfml_clion_template-master.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/sfml_clion_template-master.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/sfml_clion_template-master.dir/rule] Error 2
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/sfml_clion_template-master.dir/rule' failed
mingw32-make.exe: *** [sfml_clion_template-master] Error 2
Makefile:117: recipe for target 'sfml_clion_template-master' failed
//CMakeList.txt
cmake_minimum_required(VERSION 3.15)
project(prova1)
set(CMAKE_CXX_STANDARD 14)
## If you want to link SFML statically
set(SFML_STATIC_LIBRARIES TRUE)
## In most cases better set in the CMake cache
set(SFML_DIR "D:/Libraries/SFML/lib/cmake/SFML")
find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
add_executable(prova1 main.cpp)
target_link_libraries(prova1 sfml-graphics sfml-audio)
//main.cpp
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640,480,32),"Hello SFML");
sf::Font font;
font.loadFromFile("resources/fonts/Pacifico.ttf");
sf::Text text("Hello World",font,11);
text.setCharacterSize(32);
text.setPosition(window.getSize().x/2 - text.getGlobalBounds().width/2,
window.getSize().y/2 - text.getGlobalBounds().height/2);
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)) {
if(event.type == sf::Event::Closed){
window.close();
}
window.clear(sf::Color::Black);
window.draw(text);
window.display();
}
}
return 0;
}
//cMake
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\cristina\CLionProjects\prova1
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in D:/Libraries/SFML/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cristina/CLionProjects/prova1/cmake-build-debug
[Finished]
====================[ Build | prova1 | Debug ]==================================
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\cristina\CLionProjects\prova1\cmake-build-debug --target prova1 -- -j 2
Scanning dependencies of target prova1
[ 50%] Building CXX object CMakeFiles/prova1.dir/main.cpp.obj
[100%] Linking CXX executable prova1.exe
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:9: undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Text::Text(sf::String const&, sf::Font const&, unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:12: undefined reference to `sf::Text::setCharacterSize(unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:14: undefined reference to `sf::RenderWindow::getSize() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:14: undefined reference to `sf::Text::getGlobalBounds() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:13: undefined reference to `sf::RenderWindow::getSize() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:13: undefined reference to `sf::Text::getGlobalBounds() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:14: undefined reference to `sf::Transformable::setPosition(float, float)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:17: undefined reference to `sf::Window::isOpen() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:20: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:22: undefined reference to `sf::Window::close()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:25: undefined reference to `sf::Color::Black'
C:/Users/cristina/CLionProjects/prova1/main.cpp:25: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:26: undefined reference to `sf::RenderStates::Default'
C:/Users/cristina/CLionProjects/prova1/main.cpp:26: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:27: undefined reference to `sf::Window::display()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::~RenderWindow()'
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `ZN2sf11VertexArrayD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/VertexArray.hpp:45: undefined reference to `vtable for sf::VertexArray'
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `ZN2sf4TextD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `vtable for sf::Text'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `vtable for sf::Text'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `sf::Transformable::~Transformable()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [prova1.exe] Error 1
CMakeFiles\prova1.dir\build.make:96: recipe for target 'prova1.exe' failed
CMakeFiles\Makefile2:74: recipe for target 'CMakeFiles/prova1.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/prova1.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/prova1.dir/rule] Error 2
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/prova1.dir/rule' failed
Makefile:117: recipe for target 'prova1' failed
mingw32-make.exe: *** [prova1] Error 2
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\cristina\CLionProjects\prova1
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in D:/Libraries/SFML/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cristina/CLionProjects/prova1/cmake-build-debug
[Finished]
====================[ Build | prova1 | Debug ]==================================
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\cristina\CLionProjects\prova1\cmake-build-debug --target prova1 -- -j 2
Scanning dependencies of target prova1
[ 50%] Building CXX object CMakeFiles/prova1.dir/main.cpp.obj
[100%] Linking CXX executable prova1.exe
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:9: undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Text::Text(sf::String const&, sf::Font const&, unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:12: undefined reference to `sf::Text::setCharacterSize(unsigned int)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:14: undefined reference to `sf::RenderWindow::getSize() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:14: undefined reference to `sf::Text::getGlobalBounds() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:13: undefined reference to `sf::RenderWindow::getSize() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:13: undefined reference to `sf::Text::getGlobalBounds() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:13: undefined reference to `sf::Transformable::setPosition(float, float)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:17: undefined reference to `sf::Window::isOpen() const'
C:/Users/cristina/CLionProjects/prova1/main.cpp:20: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:22: undefined reference to `sf::Window::close()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:25: undefined reference to `sf::Color::Black'
C:/Users/cristina/CLionProjects/prova1/main.cpp:25: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:26: undefined reference to `sf::RenderStates::Default'
C:/Users/cristina/CLionProjects/prova1/main.cpp:26: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:27: undefined reference to `sf::Window::display()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:8: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:6: undefined reference to `sf::RenderWindow::~RenderWindow()'
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `ZN2sf11VertexArrayD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/VertexArray.hpp:45: undefined reference to `vtable for sf::VertexArray'
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `ZN2sf4TextD1Ev':
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `vtable for sf::Text'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `vtable for sf::Text'
D:/Libraries/SFML/include/SFML/Graphics/Text.hpp:48: undefined reference to `sf::Transformable::~Transformable()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\prova1.dir\build.make:97: prova1.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/prova1.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/prova1.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: prova1] Error 2
cmake_minimum_required(VERSION 3.15)
project(prova1)
set(CMAKE_CXX_STANDARD 14)
## If you want to link SFML statically
set(SFML_STATIC_LIBRARIES TRUE)
## In most cases better set in the CMake cache
set(SFML_DIR "D:/Libraries/SFML/lib/cmake/SFML")
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)
add_executable(prova1 main.cpp)
target_link_libraries(prova1 sfml-graphics sfml-window sfml-system)
I also tried to do what "exenda" did in this answer:====================[ Build | prova1 | Debug ]==================================
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\cristina\CLionProjects\prova1\cmake-build-debug --target prova1 -- -j 2
Scanning dependencies of target prova1
[ 50%] Building CXX object CMakeFiles/prova1.dir/main.cpp.obj
[100%] Linking CXX executable prova1.exe
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:12: undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::~Font()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\prova1.dir\build.make:90: prova1.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/prova1.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/prova1.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: prova1] Error 2
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\cristina\CLionProjects\prova1
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in D:/Libraries/SFML/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cristina/CLionProjects/prova1/cmake-build-debug
[Finished]
http://ppmlaboratorio.altervista.org/fotoClion/C1/Screenshot__2_.png (http://ppmlaboratorio.altervista.org/fotoClion/C1/Screenshot__2_.png)
cmake_minimum_required(VERSION 3.15)
project(prova1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE ON)
## If you want to link SFML statically
set(SFML_STATIC_LIBRARIES TRUE)
## In most cases better set in the CMake cache
set(SFML_DIR "D:/Libraries/SFML/lib/cmake/SFML")
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)
add_executable(prova1 main.cpp)
target_link_libraries(prova1 sfml-graphics sfml-window sfml-system)
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\cristina\CLionProjects\prova1
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe
-- Check for working C compiler: D:/mingw32/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe
-- Check for working CXX compiler: D:/mingw32/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in D:/Libraries/SFML/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cristina/CLionProjects/prova1/cmake-build-debug
[Finished]
====================[ Build | prova1 | Debug ]==================================
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\cristina\CLionProjects\prova1\cmake-build-debug --target prova1 -- -j 2
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -SC:\Users\cristina\CLionProjects\prova1 -BC:\Users\cristina\CLionProjects\prova1\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
D:/mingw32/mingw32/bin/mingw32-make.exe -f CMakeFiles\Makefile2 prova1
mingw32-make.exe[1]: Entering directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -SC:\Users\cristina\CLionProjects\prova1 -BC:\Users\cristina\CLionProjects\prova1\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E cmake_progress_start C:\Users\cristina\CLionProjects\prova1\cmake-build-debug\CMakeFiles 2
D:/mingw32/mingw32/bin/mingw32-make.exe -f CMakeFiles\Makefile2 CMakeFiles/prova1.dir/all
mingw32-make.exe[2]: Entering directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
D:/mingw32/mingw32/bin/mingw32-make.exe -f CMakeFiles\prova1.dir\build.make CMakeFiles/prova1.dir/depend
mingw32-make.exe[3]: Entering directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\cristina\CLionProjects\prova1 C:\Users\cristina\CLionProjects\prova1 C:\Users\cristina\CLionProjects\prova1\cmake-build-debug C:\Users\cristina\CLionProjects\prova1\cmake-build-debug C:\Users\cristina\CLionProjects\prova1\cmake-build-debug\CMakeFiles\prova1.dir\DependInfo.cmake --color=
Scanning dependencies of target prova1
mingw32-make.exe[3]: Leaving directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
D:/mingw32/mingw32/bin/mingw32-make.exe -f CMakeFiles\prova1.dir\build.make CMakeFiles/prova1.dir/build
mingw32-make.exe[3]: Entering directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
[ 50%] Building CXX object CMakeFiles/prova1.dir/main.cpp.obj
D:\mingw32\mingw32\bin\g++.exe -DSFML_STATIC @CMakeFiles/prova1.dir/includes_CXX.rsp -g -std=gnu++14 -o CMakeFiles\prova1.dir\main.cpp.obj -c C:\Users\cristina\CLionProjects\prova1\main.cpp
[100%] Linking CXX executable prova1.exe
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E cmake_link_script CMakeFiles\prova1.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E remove -f CMakeFiles\prova1.dir/objects.a
D:\mingw32\mingw32\bin\ar.exe cr CMakeFiles\prova1.dir/objects.a @CMakeFiles\prova1.dir\objects1.rsp
D:\mingw32\mingw32\bin\g++.exe -g -Wl,--whole-archive CMakeFiles\prova1.dir/objects.a -Wl,--no-whole-archive -o prova1.exe -Wl,--out-implib,libprova1.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\prova1.dir\linklibs.rsp
CMakeFiles\prova1.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:12: undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::~Font()'
C:/Users/cristina/CLionProjects/prova1/main.cpp:11: undefined reference to `sf::Font::~Font()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\prova1.dir\build.make:93: prova1.exe] Error 1
mingw32-make.exe[3]: Leaving directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
mingw32-make.exe[2]: Leaving directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:78: CMakeFiles/prova1.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:85: CMakeFiles/prova1.dir/rule] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/cristina/CLionProjects/prova1/cmake-build-debug'
mingw32-make.exe: *** [Makefile:120: prova1] Error 2