Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the code:
Engine.h

C++
#ifndef _ENGINE_H
#define _ENGINE_H

#include <SFML\Graphics.hpp>

class Engine
{
private:
	//SFML Render Window
	sf::RenderWindow* window;

	//Initializes the engine
	bool Init();
	//Main Game Loop
	void MainLoop();
	//Renders one frame
	void RenderFrame();
	//Processes user input
	void ProcessInput();
	//Updates all Engine internals
	void Update();

public:
	Engine();
	~Engine();

	void Go();					//Starts the engine
};

#endif



Engine.cpp
C++
include "Engine.h"
#include <SFML\Graphics.hpp>

Engine::Engine()
{

}

Engine::~Engine()
{

}

bool Engine::Init()
{
	window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

	if(!window)
		return false;

	return true;
}

void Engine::RenderFrame()
{

}

void Engine::ProcessInput()
{
	sf::Event evt;
	//Loop through all window events
	while(window->pollEvent(evt))
	{
		if(evt.type == sf::Event::Closed)
			window->close();
	}
}

void Engine::Update()
{

}

void Engine::MainLoop()
{
	//Loop until our window is closed
	while(window->isOpen())
	{
		ProcessInput();
		Update();
		RenderFrame();
	}
}

void Engine::Go()
{
	if(!Init())
		throw "Could not initialize Engine";

	MainLoop();
}


and Main.cpp
C++
#include <Windows.h>

#include "Engine.h"

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
	Engine* engine = new Engine();

	try
	{
		engine->Go();
	}
	catch(char* e)
	{
		MessageBoxA(NULL, e, "Exception Occured", MB_OK | MB_IConerror);
	}
}



Errors:
C#
||=== Build: Debug in Game Engine (compiler: GNU GCC Compiler) ===|
obj\Debug\Engine.o||In function `ZN6Engine4InitEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|17|undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|17|undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|17|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
obj\Debug\Engine.o||In function `ZN6Engine12ProcessInputEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|31|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|37|undefined reference to `_imp___ZN2sf6Window5closeEv'|
obj\Debug\Engine.o||In function `ZN6Engine8MainLoopEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|47|undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|47|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
obj\Debug\Engine.o||In function `ZN6Engine12ProcessInputEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|37|undefined reference to `_imp___ZN2sf6Window5closeEv'|
obj\Debug\Engine.o||In function `ZN6Engine2GoEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|59|undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|59|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
obj\Debug\Engine.o||In function `ZN6Engine12ProcessInputEv':|
C:\Users\dento\Desktop\Game Engine\Engine.cpp|37|undefined reference to `_imp___ZN2sf6Window5closeEv'|
c:\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libmingw32.a(main.o):(.text.startup+0xa0)||undefined reference to `WinMain@16'|
||error: ld returned 1 exit status|
||=== Build failed: 13 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|


just noticed in the errors that some of them are in the .o file. How would I fix this?

What I have tried:

I have tried changing the names, I have tried to find what it is saying I didn't reference, other than that I don't know what to try.
Posted
Updated 31-Aug-16 13:46pm
v2
Comments
Patrice T 31-Aug-16 18:44pm    
The engine.cpp you provided is not the one that generated the error messages.

Use Improve question to update your question.
SomeRandomMan 31-Aug-16 19:51pm    
When I compile it throws errors at lines 17 (3 errors), 31 (1 error), 37 (2 error), 47 (2 errors), 59 (2 errors), and an udefined reference to @WinMain16 (Note: all of the errors thrown are undefined references). I reviewed it twice and did not see any reason for it to throw the errors.
Patrice T 31-Aug-16 19:58pm    
Engine.cpp line 17 is empty !
The engine.cpp you provided is not the one that generated the error messages.

1 solution

You are not linking against the required libraries. Check your project settings if all necessary libraries are included.

You might also get better help in the SFML forums: SFML community forums - Index[^].

But check existing questions first. They might solve your problem. This thread that might help: Build fails; 'undefined reference to..'[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900