1
General / SFML & cmake error
« on: May 22, 2018, 09:31:42 pm »
I can run cmake just fine but when I go to make the project I get this error:
This is my cmake document:
And finally my code:
CMakeFiles/RogueLike.dir/src/Main.cpp.o: In function `main':
Main.cpp:(.text+0x75): undefined reference to `sf::String::String(char const*, std::locale const&)'
Main.cpp:(.text+0x93): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
Main.cpp:(.text+0xc6): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
Main.cpp:(.text+0xf3): undefined reference to `sf::Window::isOpen() const'
Main.cpp:(.text+0x110): undefined reference to `sf::Window::pollEvent(sf::Event&)'
Main.cpp:(.text+0x12d): undefined reference to `sf::Window::close()'
Main.cpp:(.text+0x13e): undefined reference to `sf::RenderWindow::~RenderWindow()'
Main.cpp:(.text+0x17a): undefined reference to `sf::RenderWindow::~RenderWindow()'
Main.cpp:(.text+0x1ab): undefined reference to `sf::RenderWindow::~RenderWindow()'
Main.cpp:(.text+0x75): undefined reference to `sf::String::String(char const*, std::locale const&)'
Main.cpp:(.text+0x93): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
Main.cpp:(.text+0xc6): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
Main.cpp:(.text+0xf3): undefined reference to `sf::Window::isOpen() const'
Main.cpp:(.text+0x110): undefined reference to `sf::Window::pollEvent(sf::Event&)'
Main.cpp:(.text+0x12d): undefined reference to `sf::Window::close()'
Main.cpp:(.text+0x13e): undefined reference to `sf::RenderWindow::~RenderWindow()'
Main.cpp:(.text+0x17a): undefined reference to `sf::RenderWindow::~RenderWindow()'
Main.cpp:(.text+0x1ab): undefined reference to `sf::RenderWindow::~RenderWindow()'
This is my cmake document:
# TODO add non-linux OS compatibility
# Setup
cmake_minimum_required(VERSION 3.0)
project(RogueLike)
set(CMAKE_MODULE_PATH /usr/share/SFML/cmake/Modules)
# Libraries
# set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 COMPONENTS audio graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
endif()
# Source
set(src
src/Main.cpp
)
# Generate executable
add_executable(RogueLike ${src})
# Setup
cmake_minimum_required(VERSION 3.0)
project(RogueLike)
set(CMAKE_MODULE_PATH /usr/share/SFML/cmake/Modules)
# Libraries
# set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 COMPONENTS audio graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
endif()
# Source
set(src
src/Main.cpp
)
# Generate executable
add_executable(RogueLike ${src})
And finally my code:
#include<SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720), "Hello, world!");
while(window.isOpen()) {
sf::Event e;
while(window.pollEvent(e)) {
if(e.type == sf::Event::Closed) {
window.close();
}
}
}
}
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720), "Hello, world!");
while(window.isOpen()) {
sf::Event e;
while(window.pollEvent(e)) {
if(e.type == sf::Event::Closed) {
window.close();
}
}
}
}