C++ 使用SFML和Qt窗口不显示
在过去的两天里,我试图让SFML与Qt creator一起工作,但它就是不工作。程序在创建新窗口时失败,我不知道为什么 应用程序输出C++ 使用SFML和Qt窗口不显示,c++,qt,sfml,C++,Qt,Sfml,在过去的两天里,我试图让SFML与Qt creator一起工作,但它就是不工作。程序在创建新窗口时失败,我不知道为什么 应用程序输出 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 pr
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.
编译输出
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;
}
#包括
#包括“System.hpp”
#包括“Graphics.hpp”
int main()
{
sf::RenderWindow窗口(sf::VideoMode(200200),“SFML工作!”;
sf:圆形(100.f);
setFillColor(sf::Color::Green);
while(window.isOpen())
{
sf::事件;
while(window.pollEvent(事件))
{
如果(event.type==sf::event::Closed)
window.close();
}
window.clear();
窗口。绘制(形状);
window.display();
}
返回0;
}
哈布斯堡你好,欢迎来到stack exchange!我目前没有测试这个的设置,但我怀疑你使用了错误的库。我注意到您使用的是mingw,如果您查看sfml下载页面,有两种类型的库(SJLJ和DW2),使用错误的库可能会导致崩溃,但是调试输出可以告诉您更多有关此问题的信息。Okey,我使用了正确的库,但我没有在调试exe位置放置任何.dll文件,这就是它崩溃的原因。好吧,很高兴它现在可以工作了!享受sfml带来的乐趣!:P