我无法在此处发布此帖子,因为遇到错误。您的帖子似乎包含未正确格式化为代码的代码。因此,我将所有文本用作代码。抱歉。主持人,请解决。你好。我开始尝试开发游戏引擎。结果,我无法编译!请告诉我应该修复或添加哪些内容,以便我可以编译DLL?我注意到我是C ++的初学者,这是我第一次尝试在C ++中创建DLL库。所以。该项目具有以下CPP文件:dllmain.cpp(由VS生成),Engine.cpp,pch.cpp,World Game Engine.cpp。该项目具有头文件Engine.h。Engine.h的代码:#pragma一次#include
using namespace sf;
class Engine
{
private:
RenderWindow m_Window;
void input();
void update(float dtAsSeconds);
void draw();
public:
Engine();
void start();
};
Code of Engine.cpp:
#include "stdafx.h"
#include "Engine.h"
#include "pch.h"
Engine::Engine()
{
Vector2f resolution;
resolution.x = VideoMode::getDesktopMode().width;
resolution.y = VideoMode::getDesktopMode().height;
m_Window.create(VideoMode(resolution.x, resolution.y),
"World Game Engine",
Style::Fullscreen);
}
void Engine::start()
{
Clock clock;
while (m_Window.isOpen())
{
Time dt = clock.restart();
float dtAsSeconds = dt.asSeconds();
input();
update(dtAsSeconds);
draw();
}
}
Code of World Game Engine.cpp:
#include "stdafx.h"
#include "Engine.h"
#include "pch.h"
int init()
{
Engine engine;
engine.start();
return 0;
}
So, I get a lot of errors.
I can’t create a screenshot because I have a Russian version of VS. But if necessary, I can switch to the English version and take a screenshot.
SFML has been linked.
Thanks in advance!
stdafx.h和pch.h都是预编译的头,这是Visual Studio在启动项目时为您创建的头。据我所知(唯一可能是错误的),唯一的区别是,根据VS的版本,它会创建stdafx.h(较旧的版本)或pch.h(较新的版本)。您只应#include项目树中存在的头文件。再次检查它,并删除#include之一,具体取决于您拥有的头文件。另外,如果您正在使用任何外部.dll文件->将它们放在VS项目的/ Debug目录中。 (出现在解决方案文件夹前的.sln)。试试吧!