Well. I've been developing a small game. This is what I have done: I've created a Engine project, which has these files in it:

Geometry.h
Engine.h
Engine.cpp

Now, I've created another project, called Test, and it has only one file in it: Main.cpp. I've included the Engine.h by modifying the Project Settings a bit, it's all working but I keep getting these Linker Errors.

1>Compiling...
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Engine::Run(void)" (?Run@Engine@@QAEXXZ) referenced in function _WinMain@16
1>Main.obj : error LNK2001: unresolved external symbol "class Engine * g_engine" (?g_engine@@3PAVEngine@@A)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Engine::Engine(struct EngineSetup *)" (??0Engine@@QAE@PAUEngineSetup@@@Z) referenced in function _WinMain@16
1>C:\Documents and Settings\********\My Documents\Visual Studio 2008\Projects\Test\Debug\Test.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\*******\My Documents\Visual Studio 2008\Projects\Test\Test\Debug\BuildLog.htm"
1>Test - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

As far as I understand it, it won't find or try to find the class functions which are in Engine.cpp. How could I fix this?

Thanks in forwards.

Also, 'void Engine::Run()' is correctly done in Engine.cpp.

I've done a g_engine = this; to the engine constructor and Engine *g_engine = NULL; to the very beginning of the Engine.cpp file.

At the bottom of Engine.h I have extern Engine *g_engine;

In the test project you have either (1) include Engine.cpp so that it's compiled along with test.cpp, or (2) create either a DLL or static lib out of Engine.cpp, then link test project with that lib.

I suddenly ... feel rather dumb... I never knew before that you could include Source files. I'll try both, I guess an engine.lib will come in handy later when I actually manage to get this running.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.