[英]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”用于Debug,“sfml-xxx.lib”用于Release。 糟糕的混合可能会导致崩溃。
它在这里是红色的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.