出于某种原因,我无法编译该程序,因为我可能缺少 SDL。它在 Debug 模式下编译良好,但在 Release 模式下编译不佳。我正在使用 Visual C++ 2010。我使用 VC++ 目录链接到 SDL。这是我的(小)代码。
//main.cpp
#include "main.h"
void logger::log(string logging)
{
file << logging << "\n";
}
int main(int argc, char* argv[])
{
logger logObj;
logObj.log("uShootZombies started.");
SDL_Init(SDL_INIT_EVERYTHING);
logObj.log("SDL initalized.");
SDL_Quit();
logObj.log("SDL quit.");
return 0;
}
//main.h
#include <SDL.h>
#include <fstream>
#include <string>
using namespace std;
class game
{
public:
private:
};
class logger
{
public:
void log(string logging);
logger()
{
file.open("Log.txt", ios::out);
}
~logger()
{
file.close();
}
private:
ofstream file;
};
我做错了什么?如果您需要更多信息,请询问。 ;)
最佳答案
确保将库引用添加到 Release模式和 Debug模式。我不是 100% 确定 SDL,但一些第 3 方库带有 2 种风格,即调试和发布。我相信您必须使用库文件的 Release模式来设置 IDE 的 Release模式。
关于C++ 和 SDL : Why can't I compile this program?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4160113/