Linking SMFL Library to Qt on Windows machine



  • Dear reader,

    For the last 21 hours I have been trying to find out how to use the SMF library.
    I can include the header without any problems, my program does see the headers to but
    when I try to test my scripts I get a lot of errors.

    I have been told this is because I did not yet link any library to my project.

    I went to my .PRO file, right clicked on it and indeed... a option to link a library but...

    1. Three options... which one should I pick?
    2. What files (or folders) should I copy to my project (SMFL folders to my project)
    3. How do I add them, and which files do I need to add?

    I hope someone can help me out on this matter.

    Yours sincerely,

    GZ


  • Moderators

    You need to provide some more information. For instance it would help if you are posting your .pro file and possibly addtional information of importance.



  • Well, it is a new project. I havent done anything yet.
    I am just following the tutorials on SMFL boards.

    My pro file at this point:

    @#-------------------------------------------------

    Project created by QtCreator 2011-08-21T19:06:23

    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = game
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp
    @

    and my cpp file

    @#include <SFML/Window.hpp>

    int main()
    {
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "GroundZero");

    // Start main loop
    bool Running = true;
    while (Running)
    {
        App.Display();
    }
    
    return EXIT_SUCCESS;
    

    }
    @

    best regards,

    GZ


  • Moderators

    You need to add a "libs parameter":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#libs to your .pro



  • Indeed, you need to link against your sfml libraries by adding a LIBS statement, like :

    @
    LIBS *= -L"path/to/your/SFML/libraries" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main
    @

    This may not be the exact libraries, but you get the idea ;)



  • Yeah I see now thank you very much!!!

    Only 1 small problem... SFML 2.0 does not include .lib files... is that correct? all I can find is .h (header) files :)

    Thank you very much for your replies so far guys!

    EDIT:

    SFML\extlibs\libs-msvc\x86

    has some lib files but when i add those and press "RUN" it still asks for more lol. Ill try figuring it out if I cant solve it ill 'edit' this post :D


  • Moderators

    for including header files you can use "INCLUDEPATH ":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#includepath
    Is it a template library?
    Can you post a link to the source?



  • yeah will do give me a couple of minutes please :)

    edit:

    :-1: error: cannot find -lsfml-freetype

    is the error I am receiving after doing:

    @LIBS *= -L"SFML/libs/" -lsfml-freetype -lsfml-glew -lsfml-jpeg -lsfml-openal32 -lsfml-sndfile@

    In my .pro file.

    The .lib files I included:

    http://img30.imageshack.us/img30/8214/unled2tw.png

    I downloaded this SFML : https://github.com/LaurentGomila/SFML/tarball/master
    The page it self is located here: http://www.sfml-dev.org/download.php -> SMFL 2.0 Snapshot

    My code at this moment:

    @#-------------------------------------------------

    Project created by QtCreator 2011-08-22T12:53:05

    #-------------------------------------------------

    QT += core gui

    TARGET = game
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS +=

    LIBS *= -L"SFML/libs/" -lsfml-freetype -lsfml-glew -lsfml-jpeg -lsfml-openal32 -lsfml-sndfile
    @

    and the .cpp file

    @#include <SFML/Window.hpp>

    int main()
    {
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Start main loop
    bool Running = true;
    while (Running)
    {
        App.Display();
    }
    
    return EXIT_SUCCESS;
    

    }
    @

    I also uploaded a copy of my whole directory incl. libs, .h and .cpp files here:
    http://uploading.com/files/96mdfac4/files.rar/

    I am using Microsoft Windows 7 Professional with Qt Creator :)



  • You should link against .a libraries instead of .lib ones (located in libs-mingw)


  • Moderators

    I guess octal is correct.
    I have no experience with mingw on win7. I have visual studio installed there. On ubuntu I am using qt creator.



  • Yeah I tried that... when i remove all .lib and paste the new files (.a) it still asks for -lsfml-freetype :P



  • Mhh yes, you're linking the wrong libraries, those are the dependancies needed to compile the SFML.

    Since I've never used the SFML 2.0, you should follow the "official instructions":http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php



  • Oke, will give that one a try :D thanks!!!
    but...

    set PATH=%PATH%;your_mingw_folder\bin
    cmake

    Cant find where to fill in that path and stuff... and where do i type in the command cmake?


  • Moderators

    path is the environment variable path in your example. So with
    @ set PATH=%PATH%;your_mingw_folder\bin@
    you are extending that the path setting in your environment.
    cmake you have to type on the command prompt.
    [edit] Are you working on the command prompt?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.