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

Author Topic: SFML doesn't work with my Qt Creator  (Read 6078 times)

0 Members and 1 Guest are viewing this topic.

salan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
SFML doesn't work with my Qt Creator
« on: March 19, 2016, 05:52:31 pm »
Hi,

I have Qt with mingw492 compiler. I downloaded GCC 4.9.2 MinGW (DW2) - 32-bit SFML.

This is my *.pro file

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

LIBS += -LD:\Programmin\DTW\SFML2\lib

CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-network -clsfml-window -lsfml-system
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-network-d -lsfml-window-d -lsfml-system-d

INCLUDEPATH += D:\Programmin\DTW\SFML2\include
DEPENDPATH += D:\Programmin\DTW\SFML2\include


SOURCES += main.cpp
 

and this is my c++ code
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace std;

int main(int argc, char *argv[])
{
    sf::RenderWindow Window(sf::VideoMode(640, 480, 32), "Recording Sounds");

    if(!sf::SoundBufferRecorder::isAvailable()){
        cout << "something went wrong" << endl;
    }

    sf::SoundBufferRecorder recorder;
    sf::SoundBuffer buffer;
    sf::Sound sound;

    while(Window.isOpen()){
        sf::Event Event;
        while(Window.pollEvent(Event)){
            switch(Event.type){

            case sf::Event::Closed:
                Window.close();
                break;
            case sf::Event::KeyPressed:
                if(Event.key.code == sf::Keyboard::R){
                    recorder.start();
                }
                else if(Event.key.code == sf::Keyboard::S){
                    recorder.stop();
                    buffer = recorder.getBuffer();
                    sound.setBuffer(buffer);
                    sound.play();
                }
            }
        }
        Window.clear(sf::Color(0, 240, 255));
        Window.display();
    }
    getchar();
    return 0;
}
 

If I run my project I have only cmd window. My qt doesn't appear SFML window and I don't know what I should to do.  I work on Windows 10.

Anybody can help me what I did wrong?
I will appreciate your help.
« Last Edit: March 19, 2016, 05:54:26 pm by salan »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML doesn't work with my Qt Creator
« Reply #1 on: March 19, 2016, 05:58:37 pm »
Does it compile, i.e. do you get any compiler errors?
Have you copied the DLLs to the correct place?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

salan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re : SFML doesn't work with my Qt Creator
« Reply #2 on: March 19, 2016, 06:05:45 pm »
Yes, I checked few times if it is in correct place.
I don't have errors, but few warnings.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: SFML doesn't work with my Qt Creator
« Reply #3 on: March 19, 2016, 07:20:13 pm »
What if you open the executable via explorer or command line?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

salan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re : SFML doesn't work with my Qt Creator
« Reply #4 on: March 19, 2016, 07:36:39 pm »
Still the same.
For sure I have good code in file .pro?

Satus

  • Guest
Re: SFML doesn't work with my Qt Creator
« Reply #5 on: March 19, 2016, 08:49:08 pm »
Quote
CONFIG += console
You sure that this line is correct?

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: SFML doesn't work with my Qt Creator
« Reply #6 on: March 19, 2016, 08:51:25 pm »
There is a mispelled library for your release build:
-clsfml-window

This is my pro file for statically linked projects:
TEMPLATE = app
CONFIG += console c++14
CONFIG -= app_bundle
CONFIG -= qt
DEFINES += SFML_STATIC
LIBS += -Ld:/libraries/lib
INCLUDEPATH += d:/libraries/include

CONFIG(release, debug|release): LIBS += -lsfml-graphics-s -lfreetype -ljpeg -lsfml-window-s -lopengl32 -lgdi32 -lsfml-system-s -lwinmm

CONFIG(debug, debug|release): LIBS += -lsfml-graphics-s-d -lfreetype -ljpeg -lsfml-window-s-d -lopengl32 -lgdi32 -lsfml-system-s-d -lwinmm

SOURCES += main.cpp

 

salan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re : SFML doesn't work with my Qt Creator
« Reply #7 on: March 19, 2016, 09:09:22 pm »
SpeCter you're right, but this hasn't resolve my problem yet.
I don't have any errors. If I run project I have only cmd window without any presenece SFML.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: SFML doesn't work with my Qt Creator
« Reply #8 on: March 19, 2016, 09:41:46 pm »
Have you tried debugging to see where your program is getting stuck at? (ie, put a breakpoint at the first line of your main() and step through until you find the issue.)

salan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re : SFML doesn't work with my Qt Creator
« Reply #9 on: March 19, 2016, 09:47:38 pm »
So, what should I to do?
I am a newbie.

Kiecker

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: SFML doesn't work with my Qt Creator
« Reply #10 on: July 07, 2016, 01:50:15 pm »
I made a tutorial on how to add SFML to Qt Creator

I know the video is bad.