I'm currently experimenting with some stuff in Ubuntu, and thought I'd try SFML as well. I installed the extra required dependencies, downloaded the latest SFML release and compiled etc.
So I've got SFML up and running now using KDevelop4 (Which I choose over Eclipse C++ due to some annoying bugs). As KDevelop4 uses CMake to run it's applications, I've got a CMakeLists.txt that looks like this:
cmake_minimum_required(VERSION 2.8)
project(sfml)
set(SFML_INCLUDE_DIR "${PROJECT_BINARY_DIR}/libs/sfml/include/")
set(SFML_LIBRARY_DIR "${PROJECT_BINARY_DIR}/libs/sfml/lib/")
include_directories(${SFML_INCLUDE_DIR})
add_executable(sfml Engine/Foobar.cpp main.cpp)
find_library(SFML_AUDIO NAMES sfml-audio HINTS ${SFML_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(SFML_GRAPHICS NAMES sfml-graphics HINTS ${SFML_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(SFML_WINDOW NAMES sfml-window HINTS ${SFML_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(SFML_SYSTEM NAMES sfml-system HINTS ${SFML_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(SFML_NETWORK NAMES sfml-network HINTS ${SFML_LIBRARY_DIR} NO_DEFAULT_PATH)
target_link_libraries(sfml
${SFML_AUDIO}
${SFML_GRAPHICS}
${SFML_WINDOW}
${SFML_SYSTEM}
${SFML_NETWORK})
install(TARGETS sfml RUNTIME DESTINATION bin)
add_subdirectory(Engine)
So I have a folder called "libs" in the same directory as my executable, where I keep the SFML libraries and includes. So I proceed to build this, and run it, getting a nice little SFML window.. BUT.. here's what I don't understand:
- If I move my executable, as well as the lib folder far away from eachother, I can still run the executable without problem. I assume it uses the libs located in /usr/local/lib to link to, but shouldn't it search for libraries in the folder I specified in CMake? Or look for them in the same directory as the executable is in?
- So I think everything is fine and send my friend the executable as well as the SFML libraries, but he's missing those extra dependencies that you had to install for Linux (according to tutorial). So I would assume I have to export those libraries to him as well or tell him to download them through the package manager? I'm fairly new to Linux and Ubuntu, but this seems like a kinda unuserfriendly way to send around a program
- If the above seems kinda cluttered, a quick summary: Executables look for their libs in /usr/local/libs or in the directory the .exe is in? Does the person I send the program to need all the extra linux dependencies too, if he's running Linux? Why don't Windows for example need those extra dependencies?