我试图让SFML在最近2天内与Qt创建者一起工作,但它只是不起作用。该程序无法创建新窗口,我不知道为什么。
应用输出
Starting E:\Programiranje\QT programi\build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\SMFLConsoleGame.exe...
The program has unexpectedly finished.
E:\Programiranje\QT programi\build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\SMFLConsoleGame.exe crashed
编译输出
14:57:51: Running steps for project SMFLConsoleGame...
14:57:51: Configuration unchanged, skipping qmake step.
14:57:51: Starting: "E:\Programiranje\QT\Tools\mingw482_32\bin\mingw32-make.exe"
E:/Programiranje/QT/Tools/mingw482_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'E:/Programiranje/QT programi/build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_CORE_LIB -I..\SMFLConsoleGame -I"..\..\SFML\include\SFML" -I"..\..\QT\5.3\mingw482_32\include" -I"..\..\QT\5.3\mingw482_32\include\QtCore" -I"debug" -I"." -I"..\..\QT\5.3\mingw482_32\mkspecs\win32-g++" -o debug\main.o ..\SMFLConsoleGame\main.cpp
g++ -Wl,-subsystem,console -mthreads -o debug\SMFLConsoleGame.exe debug/main.o -LE:/Programiranje/SFML/lib -lsfml-system -lsfml-window -lsfml-graphics -lsfml-audio -LE:/Programiranje/QT/5.3/mingw482_32/lib -lQt5Cored
mingw32-make[1]: Leaving directory 'E:/Programiranje/QT programi/build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug'
14:57:52: The process "E:\Programiranje\QT\Tools\mingw482_32\bin\mingw32-make.exe" exited normally.
14:57:52: Elapsed time: 00:02.
的.pro
QT += core
QT -= gui
TARGET = SMFLConsoleGame
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
LIBS+= -LE:/Programiranje/SFML/lib \
-lsfml-system \
-lsfml-window \
-lsfml-graphics \
-lsfml-audio
INCLUDEPATH += E:/Programiranje/SFML/include/SFML
CONFIG += c++11
的main.cpp
#include <iostream>
#include "System.hpp"
#include "Graphics.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
答案 0 :(得分:1)
Hello Habsburg,欢迎来堆叠交流!我目前没有设置来测试这个,但我怀疑你使用的是错误的库。我注意到你正在使用mingw,如果你看看sfml下载页面有2种类型的库(SJLJ和DW2),使用错误的库会导致崩溃,但是,调试输出可以告诉更多关于问题。