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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vrige

Pages: [1]
1
General / Re: character movement
« on: December 05, 2019, 11:45:00 am »
I have found an old solution for my code.
https://en.sfml-dev.org/forums/index.php?topic=24242.0 based on https://github.com/SFML/SFML-Game-Development-Book/blob/master/01_Intro/Source/Game.cpp
Thank you for the help!

                            if (aStar.astar()) {
                                vector<char> path = aStar.getEasierToReadPath();

                                sf::Clock clock;
                                sf::Time timeSinceLastUpdate = sf::Time::Zero;
                                float frametime = 1.0f / 6.0f; //รจ un immagine al secondo
                                sf::Time frameTime = sf::seconds(frametime);

                                for (char iter : path) {
                                    while(true){
                                        sf::Time elapsedTime = clock.restart();
                                        timeSinceLastUpdate += elapsedTime;

                                        if (timeSinceLastUpdate > frameTime){

                                            timeSinceLastUpdate -= frameTime;
                                            player.movePlayer(iter);
                                            view.setCenter(player.getPos().x * player.getPlayerSize().x, player.getPos().y * player.getPlayerSize().y);
                                            player.setIsMoved(false);

                                            window.setView(view);
                                            window.clear(sf::Color::White);
                                            window.draw(map);
                                            window.draw(player);
                                            window.display();

                                            break;
                                        }
                                    }
                                }
                            }

2
General / Re: character movement
« on: December 04, 2019, 10:09:12 am »
Now it shows that the character can go from the start to the goal, but i would like to show all the intermediate steps. I would like to show graphically the path chosen by AStar. So i have tried to make it sleeps in each steps, but it didn't work.

3
General / character movement
« on: December 03, 2019, 03:39:14 pm »
I am having some problems trying to show the moviment of my character after i have clicked 'A'.
This is all my code: https://github.com/vrige/sfml_1.
This is the solution that i tried, but it didn't work:
             
 chrono::milliseconds timespan(500);
 /*
     code
*/

      else if (event.key.code == sf::Keyboard::A) {
                        cout << "tasto A" << endl;
                        if (!player.getIsMoved()) {                  

                            if (aStar.astar()) {
                                vector<char> path = aStar.getEasierToReadPath();
                           
                                for (char iter : path) {
                                    player.movePlayer(iter);

                                    this_thread::sleep_for(timespan); //here
                                    player.setIsMoved(false);
                                }
                            }
                        }
                    }
Sorry for my english.

4
General / Re: setting SFML on Clion
« on: November 24, 2019, 10:18:47 am »
thank you so much!! That was my error! thank you so much!
Now it works!

5
General / Re: setting SFML on Clion
« on: November 22, 2019, 04:36:20 pm »
D:/Libraries/SFML/lib/sfml-graphics-s-d.lib D:/Libraries/SFML/lib/sfml-window-s-d.lib D:/Libraries/SFML/lib/sfml-system-s-d.lib -lwinmm -lgdi32 -lOpenGL32 D:/Libraries/SFML/lib/freetype.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32

6
General / Re: setting SFML on Clion
« on: November 22, 2019, 03:40:05 pm »
I used this line: set(CMAKE_VERBOSE_MAKEFILE ON).
#include <SFML/Graphics.hpp>
#include <iostream>

int main() {
    std::cout<<"ciao"<<std::endl;

    sf::Font font;
    font.loadFromFile("resources/fonts/Pacifico.ttf");

    return 0;
}
Code: [Select]
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

7
General / Re: setting SFML on Clion
« on: November 22, 2019, 10:48:47 am »
I tried to clear my cMake cache with "reset cMake and reload project", but it didn't work.
#include <SFML/Graphics.hpp>
#include <iostream>

int main() {
    std::cout<<"ciao"<<std::endl;

    sf::Font font;
    font.loadFromFile("resources/fonts/Pacifico.ttf");

    return 0;
}
Code: [Select]
====================[ 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

8
General / Re: setting SFML on Clion
« on: November 21, 2019, 01:33:10 pm »
I changed it just a little bit:
Code: [Select]
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:
https://stackoverflow.com/questions/26602471/how-to-run-sfml-in-clion-error-undefined-reference-to
so i added D:\libraries\SFML\bin\ to my env variable Path, but it didn't work.
 

9
General / Re: setting SFML on Clion
« on: November 21, 2019, 11:02:47 am »
can someone help me?
Is there a Clion+sfml tutorial?

10
General / Re: setting SFML on Clion
« on: November 19, 2019, 01:24:04 pm »
I have tried to download it, but it didn't solve my problem.
I really need SFML to do a project and probably i did some stupid errors, please help me to find them.
This is what i download: 
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-posix/dwarf/i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z/downloadMinGW Builds 7.3.0 (32-bit)

Code: [Select]
"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]
Code: [Select]
====================[ 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

11
General / Re: setting SFML on Clion
« on: November 18, 2019, 04:15:27 pm »
it still doesn't work. Can you help me a little bit more? I don't really know what to do.

Code: [Select]
//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

12
General / setting SFML on Clion
« on: November 17, 2019, 06:15:33 pm »
I have read many other topics about this, but they didn't solve my problem. I have followed this: https://github.com/perebalsach/sfml_clion_template. What should i do to make this program work? Managing the cMakeFiles is not my cup of tea Please don't answer by only linking an other answer. Sorry for my english
Code: [Select]
//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;
}
Code: [Select]
//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

Pages: [1]
anything