简体   繁体   中英

Using SFML with Qt creator?

I've recently began learning the SFML API for learning purposes but it seems to me like it only supports Codeblocks IDE and Visual Studio. I dislike both IDEs for my own ideas and I like the IDE that comes with Qt instead.

Is it possible to basically use SFML within the Qt creator?

EDIT:

I know some of you may some day find this on google, after struggling for 8 days to set up sfml to work with qt creator I've found the sollution:

step 1: Download the VS version of SFML from the website (NOT codeblocks version) step 2: copy the DLLs from C:\SFML-1.6\lib to your system32 directory step 3: open qt creator, make a plain C++ project, open your.pro file and add these lines:

    INCLUDEPATH += C:\SFML-1.6\include
LIBS += C:\SFML-1.6\lib\sfml-system.lib \
    C:\SFML-1.6\lib\sfml-window.lib \
    C:\SFML-1.6\lib\sfml-graphics.lib \
    C:\SFML-1.6\lib\sfml-audio.lib \
    C:\SFML-1.6\lib\sfml-network.lib

And you're done

Short answer: Yes.

The IDE doesn't really matter all that much. The compiler does. Depending on the compiler used by Qt Creator, you download the appropriate SFML package. Most likely the MinGW based version will work just fine with your default install of Qt Creator. (I believe that relies on MinGW?)

All that then remains to be done is place SFML in its own directory and making sure that you set up the correct paths in your Qt Creator project. There's not much to it really.

I know i'm a little bit late to the party but:

SFML library is 100% compatible with qtcreator especially qmake.

  1. Download SFML from https://www.sfml-dev.org/download/sfml/2.5.1/ . Bottom right minGW (You most likely have mingw on qt)
  2. Place it somewhere you will know where it is. I usually put it in "C:/SFML-2.5.1"
  3. There's a simple copy pasta you can add to your qmake '.pro' file:
INCLUDEPATH += "C:/SFML-2.5.1/include"
LIBS += -L"C:/SFML-2.5.1/lib"
CONFIG(debug, debug|release){
    LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-system-d -lsfml-window-d
} else {
    LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window
}

The 'INCLUDEPATH' includes the headers into your project where as the 'LIBS' adds the library file path. The 'CONFIG()' tells qt if you're running DEBUG mode or RELEASE mode.

This copy pasta is fun because you can also configure a custom wizard and make qt dropdown show you a 'create new sfml c++' project by just editing its profile with this.

  1. Last but not least are the needed.dll files from 'C:\SFML-2.5.1\bin' You can add only the ones you need or all of them if you're lazy. You can do this by copying them into the BUILD folder of your project. (to find the build folder by default its a folder in the same path as your project folder with the name of your project prefixed by 'build-' or 'release-')
  1. Make simple c++ project
  2. Choose QMake build system
  3. in project.pro add 2 lines:

CONFIG += link_pkgconfig

PKGCONFIG += sfml-all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM