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

Author Topic: problem in using SFML in linux  (Read 3131 times)

0 Members and 1 Guest are viewing this topic.

grando

  • Newbie
  • *
  • Posts: 4
    • View Profile
problem in using SFML in linux
« on: October 29, 2010, 05:08:38 pm »
hi to everyone
i just installed sfml in my ubuntu 10.10 throw synaptic package manager!
but now i dont know how to use it!!! even i cannot compile those official samples of sfml!! i tried it in Qt Creator and KDevelop !! both of theme giving me a lot of errors like Undefined Refrence ......
please tell me exactly what should i do???? ( a complete beginner guide )

Thanks A lot!!!
 :oops:

Rock_Hardbuns

  • Newbie
  • *
  • Posts: 10
    • View Profile
problem in using SFML in linux
« Reply #1 on: October 29, 2010, 05:26:48 pm »
Undefined reference means that you are not linking to the libs properly.

I am not familiar with the IDEs you've tried (I just use a text editor), but they should have some place to add library names to the build settings.

grando

  • Newbie
  • *
  • Posts: 4
    • View Profile
problem in using SFML in linux
« Reply #2 on: October 29, 2010, 05:30:39 pm »
is there any way that i could use it without any configuration!???
i mean ide automatically verify SFML libraries!!

Rock_Hardbuns

  • Newbie
  • *
  • Posts: 10
    • View Profile
problem in using SFML in linux
« Reply #3 on: October 29, 2010, 06:06:01 pm »
The linker will need to be told what to do. Some IDEs have template projects and such that sets that stuff up (CodeBlocks maybe?), but you might as well get used to figuring that stuff out.

Link errors are difficult enough even when you know how it works.

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
problem in using SFML in linux
« Reply #4 on: October 29, 2010, 06:53:00 pm »
I don't know about qtcreator, but for kdevelop you must use cmake, which makes things a bit complicated.

You can use codeblocks and then in project options there is an option to link to libraries (make sure you link in both Release and Debug mode). You must add sfml-system, sfml-window, sfml-graphics, sfml-audio and sfml-network (depending on what you are doing).

Or if you want to use kdevelop, you must download FindSFML.cmake (available in the forums), put it into a subdirectory which I'll call cmake_modules (inside your project) and make a CMakeLists.txt that looks something like this:

Code: [Select]
cmake_minimum_required(VERSION 2.8)
project(nameOfYourProject)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(SFML 2 COMPONENTS graphics window system audio network REQUIRED)

include_directories(${SFML_INCLUDE_DIRS})
ADD_EXECUTABLE(nameOfYourProject main.cpp someOtherFile.cpp)

target_link_libraries(nameOfYourProject ${SFML_LIBRARIES})