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 - Arknode

Pages: [1]
1
General / how to use SFML LIbarys in Cmake ?
« on: August 13, 2013, 05:10:08 pm »
Hello all,

iam new at cmake and i do not know really how link a libary in it. I start with the book "mastering cmake" and i think its really bad. Whatever.

I have compiled the libary from SFML by my own on Ubuntu. The libarys is located in the std-path usr/local/lib and the compiling by command line works fine.

First i found the FindSFML.cmake on the book-github dir. https://github.com/SFML/SFML-Game-Development-Book/blob/master/CMake/FindSFML.cmake  i use it with this CMakeLists.txt

Code: [Select]
cmake_minimum_required (VERSION 2.8)
project(SFML_Test)

set (TEST_SRCS main.cpp check.cpp)

find_package(SFML COMPONENTS graphics window system)
add_executable (SFML_Test ${TEST_SRCS})
target_link_libraries(SFML_Test ${SFML_LIBRARIES})

If i run cmake. it shows this

Quote
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning at CMakeLists.txt:6 (find_package):
  By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SFML", but
  CMake did not find one.

  Could not find a package configuration file provided by "SFML" with any of
  the following names:

    SFMLConfig.cmake
    sfml-config.cmake

  Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
  "SFML_DIR" to a directory containing one of the above files.  If "SFML"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring done
-- Generating done
-- Build files have been written to: /...

If i run make now

Quote
[ 50%] Building CXX object CMakeFiles/SFML_Test.dir/main.cpp.o
[100%] Building CXX object CMakeFiles/SFML_Test.dir/check.cpp.o
Linking CXX executable SFML_Test
CMakeFiles/SFML_Test.dir/main.cpp.o: In function `main':
main.cpp:(.text+0xf7): undefined reference to `sf::String::String(char const*, std::locale const&)'
main.cpp:(.text+0x115): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
main.cpp:(.text+0x148): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
main.cpp:(.text+0x182): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
main.cpp:(.text+0x18e): undefined reference to `sf::Color::Green'
main.cpp:(.text+0x196): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
main.cpp:(.text+0x1b4): undefined reference to `sf::Window::close()'
main.cpp:(.text+0x1cd): undefined reference to `sf::Window::pollEvent(sf::Event&)'
main.cpp:(.text+0x1fa): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
main.cpp:(.text+0x217): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
main.cpp:(.text+0x22e): undefined reference to `sf::RenderStates::Default'
main.cpp:(.text+0x239): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
main.cpp:(.text+0x248): undefined reference to `sf::Window::display()'
main.cpp:(.text+0x257): undefined reference to `sf::Window::isOpen() const'
main.cpp:(.text+0x282): undefined reference to `sf::RenderWindow::~RenderWindow()'
main.cpp:(.text+0x2b1): undefined reference to `sf::RenderWindow::~RenderWindow()'
main.cpp:(.text+0x2f7): undefined reference to `sf::RenderWindow::~RenderWindow()'
CMakeFiles/SFML_Test.dir/main.cpp.o: In function `sf::CircleShape::~CircleShape()':
main.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x13): undefined reference to `vtable for sf::CircleShape'
main.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x1f): undefined reference to `vtable for sf::CircleShape'
main.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x2b): undefined reference to `sf::Shape::~Shape()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [SFML_Test] Fehler 1
make[1]: *** [CMakeFiles/SFML_Test.dir/all] Fehler 2
make: *** [all] Fehler 2

Maybe anyone knows how to fix this?

best regards

Pages: [1]
anything