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

Author Topic: [Weird] Linking problems  (Read 4373 times)

0 Members and 1 Guest are viewing this topic.

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Weird] Linking problems
« on: December 12, 2012, 05:13:50 pm »
Hello, I'm trying out SFML for the first time and everything worked fine, with the example code. So then I started integrating it with my project and came across a really weird problem. So I started with this piece of code:
#include <SFML/Window.hpp>

/*
 * @brief Main function, entry point
 *
 * @return      Exit code
 */


int main() {
        sf::Window window;
        return 0;
}
 

And got the following errors:
Quote
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Clock::Reset()'
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Unicode::UTF8Offsets'
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Clock::Clock()'
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Clock::GetElapsedTime() const'
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Unicode::UTF8TrailingBytes'
/usr/local/lib/libsfml-window.so: undefined reference to `sf::Sleep(float)'

Now, I 'fixed' it like so:
#include <SFML/Window.hpp>

/*
 * @brief Main function, entry point
 *
 * @return      Exit code
 */


int main() {
        sf::Clock testClock; //this fixed the problem???!!!!
        sf::Window window;
        return 0;
}
 



it builds fine, no errors at all...

Someone please help me?

By the way, I'm using SFML 1. 6 on an Ubuntu machine
« Last Edit: December 12, 2012, 05:16:27 pm by tavrin »

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [Weird] Linking problems
« Reply #1 on: December 15, 2012, 04:58:50 pm »
anyone? *bump*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [Weird] Linking problems
« Reply #2 on: December 15, 2012, 05:13:38 pm »
Did you link to sfml-system?
Laurent Gomila - SFML developer

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [Weird] Linking problems
« Reply #3 on: December 16, 2012, 12:08:48 pm »
Did you link to sfml-system?

Yes, I do so in my src/CMakeLists.txt
Quote
set(CMAKE_MODULE_PATH "../cmake_modules/" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: [Weird] Linking problems
« Reply #4 on: December 16, 2012, 12:17:27 pm »
Yes, I do so in my src/CMakeLists.txt
Quote
set(CMAKE_MODULE_PATH "../cmake_modules/" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)
No, you don't. What you do is finding the package, not linking. In CMake, you can link with the command target_link_libraries. The command names are quite expressive, aren't they? ;)

And I recommend to start with SFML 2. It has more features, less bugs and is actively developed.
« Last Edit: December 16, 2012, 12:19:02 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [Weird] Linking problems
« Reply #5 on: December 16, 2012, 12:21:32 pm »
Yes, I do so in my src/CMakeLists.txt
Quote
set(CMAKE_MODULE_PATH "../cmake_modules/" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)
No, you don't. What you do is finding the package, not linking. In CMake, you can link with the command target_link_libraries. The command names are quite expressive, aren't they? ;)

And I recommend to start with SFML 2. It has more features, less bugs and is actively developed.

I tought SFML 2 was still in beta? And sorry, I forgot that portion where I actually link it, but it's in there:
Quote
#SFML lookup
set(CMAKE_MODULE_PATH "../cmake_modules/" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)

#Executable
add_executable(${exec_name} ${exec_source_files})

#Libraries
set(project_libraries config engine graphics grid input unit util)
set(external_libraries ${SFML_LIBRARIES})
set(libraries  ${project_libraries} ${external_libraries})

#Libraries Link
target_link_libraries(${exec_name} ${libraries})

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: [Weird] Linking problems
« Reply #6 on: December 16, 2012, 12:34:33 pm »
I tought SFML 2 was still in beta?
No, there is a release candidate. And you can get the newest sources from GitHub.

I suggest you try it with SFML 2, because the 1.x versions were not designed with CMake integration in mind. For example, the FindSFML module has been written for version 2.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [Weird] Linking problems
« Reply #7 on: December 16, 2012, 01:05:44 pm »
I tought SFML 2 was still in beta?
No, there is a release candidate. And you can get the newest sources from GitHub.

I suggest you try it with SFML 2, because the 1.x versions were not designed with CMake integration in mind. For example, the FindSFML module has been written for version 2.

thanks, i'll give it a shot! :)

tavrin

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [Weird] Linking problems
« Reply #8 on: December 16, 2012, 01:42:38 pm »
I tought SFML 2 was still in beta?
No, there is a release candidate. And you can get the newest sources from GitHub.

I suggest you try it with SFML 2, because the 1.x versions were not designed with CMake integration in mind. For example, the FindSFML module has been written for version 2.

Using SFML 2 indeed solved the problem!