SFML仅在调试模式下工作
SFML Only Works in Debug Mode
我正试图在Visual Studio 2012中运行这个简单的SFML C++程序。它在调试模式下确实可以正常工作,但一旦我使用非调试库和DLL,程序就会在代码的第一行引发访问冲突异常。如果我删除赋值(以及赋值的依赖项),只运行'sf::VideoMode::getFullscreenModes();'它运行良好。
我已将库动态链接。
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
int main(int argCount, char** argVector) {
std::vector<sf::VideoMode> vm = sf::VideoMode::getFullscreenModes(); // Access Violation in Non-Debug Mode
sf::VideoMode videoMode;
for(unsigned i = 0; i < vm.size(); i++) {
if(vm[i].isValid()) {
videoMode = vm[i];
break;
}
std::cout << "Invalid VideoMode: " << i << std::endl;
}
sf::Window window(videoMode, "SFML OpenGL", sf::Style::Fullscreen);
glClearDepth(0.5F);
glOrtho(0, 1, 0, 1, 0, 1);
std::cout << glGetError();
glColor3f(0, 1, 0);
{
glBegin(GL_QUADS);
glVertex3i(0, 0, 0);
glVertex3i(0, 1, 0);
glVertex3i(1, 1, 0);
glVertex3i(1, 0, 0);
glEnd();
}
window.display();
while(window.isOpen()) {}
return 0;
}
简单回答:不能混合调试/发布二进制文件。
引用Visual Studio的官方SFML教程:
链接到与配置匹配的库非常重要:"sfml-xxx-d.lib"表示调试,"sfmlxxx.lib"代表发布。混合不好可能导致崩溃。
这里是红色的。
相关文章:
- 自定义内存管理器在发布模式下工作正常,但在调试模式下则不然
- 装饰器模式在 c++ 中的工作原理
- 我的代码在发布模式下不起作用,而在Qt的调试模式下工作
- 模式匹配函数的时间测量无法正常工作
- ifstream读取二进制文件在发行模式下工作,但在调试模式下不使用
- 打开文件的正确模式是什么,以便 seekp() 的工作方式与在默认模式下打开的文件相同
- 为什么在发布模式下无法访问 for 循环,但在调试中它工作正常
- Python在调试模式下以C 工作,但在EXE文件中不工作
- 该代码在调试模式下工作,但在发布模式C 中不起作用
- 当主GUI线程被阻塞时,如何从工作线程创建无模式对话框
- 如何在 QT 框架工作C++中使用变量作为正则表达式模式
- 在发行模式下开放的软崩溃(调试工作正常)
- 在 C++11 中,lambda 队列是否是工作队列的良好设计模式
- 工作线程队列的这种变体是某种模式或通用结构吗?
- 混合模式程序集(C++/CLI项目)在.NET Core上工作吗
- 在QIODevice::Append模式下打开的QFile意外工作.这是一个Qt错误吗
- 模式功能:它是如何工作的
- zmq呼吸机/工作人员/水槽模式与子流程一起不工作
- 在调试器模式下工作,但在最终版本中不起作用.为什么
- ZeroMq PUB/SUB 模式无法正常工作