gpt4 book ai didi

c++ - 使用 SFML 和 Qt 窗口不显示

转载 作者:行者123 更新时间:2023-11-28 06:46:18 25 4
gpt4 key购买 nike

在过去的 2 天里,我试图让 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 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;
}

最佳答案

你好哈布斯堡,欢迎堆栈交换!我目前没有设置来对此进行测试,但我怀疑您使用了错误的库。我注意到您正在使用 mingw,如果您查看 sfml 下载页面,则有两种类型的库(SJLJ 和 DW2),使用错误的库可能会导致崩溃,但是调试输出可以提供更多关于问题。

关于c++ - 使用 SFML 和 Qt 窗口不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24934245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com