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

Author Topic: New install of Qt 5.2.1 and SFML 2.1  (Read 6156 times)

0 Members and 1 Guest are viewing this topic.

glennp

  • Newbie
  • *
  • Posts: 3
    • View Profile
New install of Qt 5.2.1 and SFML 2.1
« on: May 13, 2014, 07:27:10 pm »
I'm not entirely sure where this question should go.  Since this is my first attempt at building a project with this configuration I thought I would put it in General.  It may belong in Window.

I have installed Qt.5.2.1 based on MVSC 2010, 32bit.  I also have installed SFML 2.1 based on MVSC 2010, 32bit.  I am new to Qt and Qt Creator but have been building successful example projects for a couple weeks now.  I am a Java programmer with some C++ education in the past.  I'm just now getting into it in a serious way.  My development is for a specific application that will run only in a windows 7 environment.  I needed access to Joystick input.  After several days of research I came across SFML.  It appears to be just what I am looking for. 

I set up a very simple project in Qt with a main window.  In the MainWindow constructor I put the following code:

    if(sf::Joystick::isConnected(0))
        qDebug() << "Joystick 1 is connected";
    else
        qDebug() << "Can't find a joystick";

The include is:
#include <SFML/Window.hpp>

In my project file I have:
LIBS += -L"C:/SFML-2.1/lib/" -lsfml-window-d

INCLUDEPATH += "C:/SFML-2.1/include"
DEPENDPATH += "C:/SFML-2.1/include"

It builds without error.  However when I try to run it from Qt Creator it crashes.  The actual messages are:

Starting D:\QT-Projects\examples\build-JoystickSFML-Desktop_Qt_5_2_1_MSVC2010_32bit_OpenGL-Debug\debug\JoystickSFML.exe...
The program has unexpectedly finished.
D:\QT-Projects\examples\build-JoystickSFML-Desktop_Qt_5_2_1_MSVC2010_32bit_OpenGL-Debug\debug\JoystickSFML.exe crashed

What am I doing wrong?

Flash

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #1 on: May 13, 2014, 10:47:21 pm »
I do not quite understand your configuration. You say that you have installed the MVSC (MSVC?) version of Qt, but then you say you are using Qt Creator.
If you are using the MSVC version of SFML, but the Qt Creator version of Qt (which compiles via mingw, IIRC), it will not work.
The SFML dlls, the Qt dlls, and your application need to be built with the same compiler.

I am running the audio module of SFML in a Qt application, and it works without a problem, but I am running Visual Studio versions only.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #2 on: May 13, 2014, 11:07:34 pm »
Quote
I do not quite understand your configuration. You say that you have installed the MVSC (MSVC?) version of Qt, but then you say you are using Qt Creator.
This is not a problem at all. QtCreator can use both gcc and VC++.

Quote
It builds without error.  However when I try to run it from Qt Creator it crashes.
You should try to use the debugger. I don't know how well it performs in QtCreator, I've always had a bad experience with debugging in QtCreator. But at least it should be able to show you where it crashes.

Also, make sure it is not a DLL issue (copy all the needed SFML DLLs in the directory where your executable is).
Laurent Gomila - SFML developer

Flash

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #3 on: May 13, 2014, 11:22:38 pm »
Quote
I do not quite understand your configuration. You say that you have installed the MVSC (MSVC?) version of Qt, but then you say you are using Qt Creator.
This is not a problem at all. QtCreator can use both gcc and VC++.
OK, this must have changed since the last time I used Qt Creator.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #4 on: May 13, 2014, 11:28:55 pm »
Must be a very long time ago then :P
Laurent Gomila - SFML developer

glennp

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #5 on: May 14, 2014, 04:27:27 pm »
Quote
I do not quite understand your configuration. You say that you have installed the MVSC (MSVC?) version of Qt, but then you say you are using Qt Creator.
This is not a problem at all. QtCreator can use both gcc and VC++.
OK, this must have changed since the last time I used Qt Creator.

Actually there is a version of Qt and Qt Creator that was built using MVSC 2010 available for download from the Qt webpage.  I needed that because a 3rd party API I am using was also built with MVSC 2010.  So in order to use Qt with my 3rd party product it has to be compatible.  I found out the hard way because I started off with the MinGW version first and nothing would link.

I am using Qt Creator because I don't have access to the full version of MVSC 2010 and the Qt plug-in does not work with express.  I don't have a choice.

I will try using debug.  My problem is I am a Java developer with minimal C++ training.  This is making a lot of things extremely difficult.  I find potential solutions to the challenges I am facing and 75% of them do not work.  So I am floundering a LOT..   :o   It's educational and I am learning a lot but it sure is frustrating!!!

So it appears I have everything configured properly in the project file?

Flash

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #6 on: May 14, 2014, 11:35:00 pm »
Actually there is a version of Qt and Qt Creator that was built using MVSC 2010 available for download from the Qt webpage.  I needed that because a 3rd party API I am using was also built with MVSC 2010.  So in order to use Qt with my 3rd party product it has to be compatible.  I found out the hard way because I started off with the MinGW version first and nothing would link.

I am using Qt Creator because I don't have access to the full version of MVSC 2010 and the Qt plug-in does not work with express.  I don't have a choice.
Laurent was right, it really was a long time ago.
If you'd rather use visual studio, you don't need the plugin. I don't use it either. You can create a Visual Studio project from a .pro file with "qmake -tp vc".

glennp

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #7 on: May 15, 2014, 10:27:21 pm »
I got it working.  Not sure what I did right.  There are a lot of conflicting posts in forums that approach the same sort of issues from different directions.  I think the most significant differences in solutions result from the differences in Windows applications and Linux applications.

The failure I was seeing as listed above was a result of not having the project configured correctly.  I didn't have the libs and dlls identified in the right places.

I think the most significant thing in the code was I needed to add sf::JoyStick::update() before the isConnected() line.  From what posts I found this only applies to the windows environment.

So after correcting the configuration and adding one line of code it is now functioning.  Now I am proceeding to add code to accept input from the joystick and provide that information to my application.

BTW..  I sort of figured you could use Qt and SFML in Express without the Qt plugin.  But you loose all of the visual capabilities of Creator.  As I am just beginning using Qt, the Creator has been a great help in building my application.  Maybe once I get comfortable enough with Qt I will consider using VS Express.  For the moment I'll stick with Creator.  Although the errors messages that come from Creator both during compile and execution leave a lot of confusion and create a lot of frustration for me.

Thanks for your responses.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #8 on: May 15, 2014, 10:55:06 pm »
Quote
I think the most significant thing in the code was I needed to add sf::JoyStick::update() before the isConnected() line.  From what posts I found this only applies to the windows environment.
It's stated in the documentation / tutorials, so it applies to all platforms.
Laurent Gomila - SFML developer

Flash

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: New install of Qt 5.2.1 and SFML 2.1
« Reply #9 on: May 15, 2014, 10:57:00 pm »
BTW..  I sort of figured you could use Qt and SFML in Express without the Qt plugin.  But you loose all of the visual capabilities of Creator. 
I don't know what other visual capabilities the Creator has, but if you are talking about GUI design, you can use Qt Designer (designer.exe in the bin folder). Just add a ui to the .pro, and qmake will set everything up so that it works in Visual Studio. Then in Visual Studio you can set designer.exe to be the default for .ui files, and it will open them on double click.

 

anything