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

Author Topic: using SFML 2.0 in Qt4  (Read 2716 times)

0 Members and 1 Guest are viewing this topic.

lagoru

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
using SFML 2.0 in Qt4
« on: September 27, 2012, 12:45:15 pm »
I have a question about using SFML 2.0 in QT 4.8.1 (MinGW). I cannot force my application to just get working (I get "undefined reference to" errors). In my .pro file i attach:

LIBS *= -L"C:\SFML\lib" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main

INCLUDEPATH += C:\SFML\include

the most important code fragments in main:

#include  "SFML/Window.hpp"
...
sf::Joystick::isConnected(0) // this where i get linking problems

I've already tried to change my build options on MSVC and try to recompile but it not helped nothing at all.
My question is: What am I doing wrong ? I already read all what I could find on the SMFL webside and google.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10827
    • View Profile
    • development blog
    • Email
Re: using SFML 2.0 in Qt4
« Reply #1 on: September 27, 2012, 12:53:16 pm »
Which role plays Qt in all of this? Or did you just mean that you're using Qt Creator as your IDE?

Also please make use of the code-tag to get a nicer formatting for code like texts.

Although I don't think that it will fix your problem, you should include SFML headers with <> instead of "" (e.g. #include <SFML/Window.hpp>).

Can you show us the full error message?
Is your Qt Creator settings set to debug, while you're trying to build with SFML release libraries (without -d sufix)?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lagoru

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: using SFML 2.0 in Qt4
« Reply #2 on: September 27, 2012, 01:04:38 pm »
Wow - you are fast  :) I'm using QTCreator as IDE.
Full error: "undefined reference to `_imp___ZN2sf8Joystick11isConnectedEj'" (so it cannot find function which i wrote in my previous post).
and also "Id returned 1 exit status" - this will rather not add anything helpful.
I'm not sure what you mean by "Is your Qt Creator settings set to debug" but I'm also debugging.

lagoru

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: using SFML 2.0 in Qt4
« Reply #3 on: September 28, 2012, 01:02:05 pm »
Anyone ? I already been sitting on this for 3 days - searching in google and looking in forums. I think that it's rather simple - but I can't just figure out what I'm doing wrong.
I don't have much experience in Qt and C++ (I'm used to Java). The only reason I'm doing that in C++ is because my professor that is leading my degree project (I'm creating Quadrocopter steering module) forces me to do that way. I already also tried to run SFML in CODE::BLOCKS (trying to go by tutorial) and also nothing working.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10827
    • View Profile
    • development blog
    • Email
Re: using SFML 2.0 in Qt4
« Reply #4 on: September 28, 2012, 01:14:50 pm »
Well I haven't really worked with Qt Creator and specially not with qmake (which turns those *.pro files into usable make files), so I'm not sure what goes wrong, but I'd still bet you have a miss match of libraries.

If you follow the Code::Blocks tutorial 1:1 it's guaranteed to work. It's just a matter of copying all the details...

Optionally you can also build your application on your own without any IDE. If the path to the MinGW binaries is added to the PATH environment variable you can just open a command line.

g++ -Ipath\to\SFML\include -Lpath\to\SFML\lib File1.cpp File2.cpp -o Output.exe -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main
« Last Edit: September 28, 2012, 01:17:21 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lagoru

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: using SFML 2.0 in Qt4
« Reply #5 on: September 28, 2012, 02:15:17 pm »
OK. Now I managed to Run SFML on CODE::BLOCKS. Of course problem in run it properly was stupid and was my fault - i forgot to copy dll to compiler executables  :-[ But still not managed to run it on Qt...

lagoru

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: using SFML 2.0 in Qt4
« Reply #6 on: September 28, 2012, 03:53:37 pm »
As I said before the problem is really stupid:
One character more and working:

new: LIBS *= -L"C:\SFML\LIBS" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main

old: LIBS *= -L"C:\SFML\LIB" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main

This mistake can be found on many websites - and I think that many careless people like me could fall for that one.

EDIT: no it's not this stupid. If you use QT Creator you must include just bin folder (not lib), i don't know why and what is the difference:

new: LIBS *= -L"C:\SFML\BIN" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main

Solved - for future user who would want to run SMFL 2.0 on QT Creator:

1. download proper version of SMFL 2.0 (depends from version of QT- it can be MSVC 2008 or MinGW (CODE::BLOCKS)- this version I have)
1. copy to pro file:

LIBS *= -L"C:\SFML\BIN" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main

INCLUDEPATH += C:\SFML\include

2. Write program and enjoy working library.
« Last Edit: September 29, 2012, 09:29:49 pm by lagoru »

 

anything