Strange Link Errors (OH GOD NO!)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Strange Link Errors (OH GOD NO!)

      Yeah... First, (and utterly irrelevant to this section) this is my first post in the forum. :) I like the site, I have to say.

      I'm getting a series of really strange linker errors, and I'm not sure why, because as far as I can tell, I shouldn't be getting them at all.

      Anywho, here they are:
      (compiling with Visual Studio.net)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CPoint::CPoint(struct tagSIZE)" (??0CPoint@@QAE@UtagSIZE@@@Z) referenced in function "public: virtual long __thiscall Sprite::VOnRender(double,float)" (?VOnRender@Sprite@@UAEJNM@Z)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CPoint::CPoint(void)" (??0CPoint@@QAE@XZ) referenced in function "public: __thiscall Sprite::Sprite(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool,unsigned int)" (??0Sprite@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_NI@Z)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CRandom::CRandom(void)" (??0CRandom@@QAE@XZ) referenced in function "public: __thiscall CBaseGame::CBaseGame(void)" (??0CBaseGame@@QAE@XZ)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CRect::CRect(int,int,int,int)" (??0CRect@@QAE@HHHH@Z) referenced in function "public: virtual class CRect const __thiscall Sprite::VGetRect(void)const " (?VGetRect@Sprite@@UBE?BVCRect@@XZ)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CRect::CRect(struct tagPOINT,struct tagPOINT)" (??0CRect@@QAE@UtagPOINT@@0@Z) referenced in function "public: virtual long __thiscall Sprite::VOnRender(double,float)" (?VOnRender@Sprite@@UAEJNM@Z)

      DotS error LNK2019: unresolved external symbol "public: __thiscall CRect::CRect(void)" (??0CRect@@QAE@XZ) referenced in function "public: __thiscall CDotSApp::CDotSApp(void)" (??0CDotSApp@@QAE@XZ)

      DotS error LNK2019: unresolved external symbol "public: bool __thiscall CZipFile::Init(unsigned short const *)" (?Init@CZipFile@@QAE_NPBG@Z) referenced in function "public: virtual bool __thiscall ResourceZipFile::VOpen(void)" (?VOpen@ResourceZipFile@@UAE_NXZ)

      DotS error LNK2019: unresolved external symbol "public: bool __thiscall CZipFile::ReadFile(int,void *)" (?ReadFile@CZipFile@@QAE_NHPAX@Z) referenced in function "public: virtual int __thiscall ResourceZipFile::VGetResource(class Resource const &,char *)" (?VGetResource@ResourceZipFile@@UAEHABVResource@@PAD@Z)

      DotS error LNK2019: unresolved external symbol "public: class CSize __thiscall CPoint::operator-(struct tagPOINT)const " (??GCPoint@@QBE?AVCSize@@UtagPOINT@@@Z) referenced in function "public: virtual long __thiscall Sprite::VOnRender(double,float)" (?VOnRender@Sprite@@UAEJNM@Z)

      DotS error LNK2019: unresolved external symbol "public: class optional<int> __thiscall CZipFile::Find(char const *)const " (?Find@CZipFile@@QBE?AV?$optional@H@@PBD@Z) referenced in function "public: virtual int __thiscall ResourceZipFile::VGetResourceSize(class Resource const &)" (?VGetResourceSize@ResourceZipFile@@UAEHABVResource@@@Z)

      DotS error LNK2019: unresolved external symbol "public: int __thiscall CZipFile::GetFileLen(int)const " (?GetFileLen@CZipFile@@QBEHH@Z) referenced in function "public: virtual int __thiscall ResourceZipFile::VGetResourceSize(class Resource const &)" (?VGetResourceSize@ResourceZipFile@@UAEHABVResource@@@Z)

      DotS error LNK2019: unresolved external symbol "public: void __thiscall CRandom::Randomize(void)" (?Randomize@CRandom@@QAEXXZ) referenced in function "public: __thiscall CBaseGame::CBaseGame(void)" (??0CBaseGame@@QAE@XZ)

      DotS error LNK2019: unresolved external symbol "public: void __thiscall CZipFile::End(void)" (?End@CZipFile@@QAEXXZ) referenced in function "public: virtual __thiscall CZipFile::~CZipFile(void)" (??1CZipFile@@UAE@XZ)

      I have some others: a couple of accidental multiple-repeat include errors due to well, accidental
      header nesting, and one other about a function
      I haven't actually defined yet. Those make sense though, so no point bringing them up.

      UPDATE: I've managed to fix the other errrors, however the ones above still remain.


      What does confuse me is the errors above as most of them (especially CPoint and CRect) are NOT custom coding. It's actually whining about methods it tells me are perfectly valid. Seeing it's a linker error, I know that it's probably a lib. include problem...

      here are my relevant project settings:
      (taken from the command line dump)
      /VERBOSE:LIB /OUT:"..\Obj\Debug/Dbg_DotS.exe" /VERSION:1.0.0 /INCREMENTAL /NOLOGO /LIBPATH:"C:\DarkBlade_Ent\DotS\DotS\Libs" /DEBUG /PDB:"..\Obj\Debug/Dbg_DotS.pdb" /MAP:"..\Obj\Debug/Dbg_DotS.map" /MAPINFO:EXPORTS /MAPINFO:LINES /SUBSYSTEM:WINDOWS /MACHINE:X86 dxerr9.lib dxguid.lib d3dx9.lib d3d9.lib winmm.lib DXUT.lib zlib.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Program Files\Microsoft DirectX 9.0 SDK (December 2004)\Lib\x86\DxErr9.lib" "\Program Files\Microsoft DirectX 9.0 SDK (December 2004)\Lib\x86\dxguid.lib" "\Program Files\Microsoft DirectX 9.0 SDK (December 2004)\Lib\x86\d3dx9.lib" "\Program Files\Microsoft DirectX 9.0 SDK (December 2004)\Lib\x86\d3d9.lib"

      and my stdafx.h is as follows:
      /*****Dawn of the Shards************************************************
      Project: DotS (Win32 Game App. + DirectX 9.0c)
      Filename: stdafx.h
      Author: Michael "HeavyBlade" Morris Company: DarkBlade Ent.
      Date of Creation: 07/28/2005 Date Modified: 07/28/2005

      Description: include file for standard system include files,
      or project specific include files that are used frequently, but
      are changed infrequently.

      Design Log:
      07/28/2005 - Initial setup begun for the new DotS game engine. Just
      got back from trip to Italy and excited to get started.
      ***********************************************************************/
      #ifndef _DOTS_WIN32APP_DIRECTX9C_STDAFX_H
      #define _DOTS_WIN32APP_DIRECTX9C_STDAFX_H

      // --Pragma for disabling irrelevant warnings:
      #pragma warning( disable : 4201 ) // nonstandard extension used - nameless struct/union - triggered in code inside MMSystem.h
      #pragma warning( disable : 4100 ) // unreferenced formal parameter - large number of places in unfinish versions.
      // also triggered by d3dx libs.
      #pragma warning( disable : 4324 ) // Triggered by d3dx libs. (dammit guys, those should be warning FREE!)
      #pragma warning( disable : 4702 ) // Triggered by d3dx libs...

      // --And our defines and headers.
      #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
      // Windows Header Files:
      #include <windows.h>
      #include <windowsx.h>
      #include <crtdbg.h>

      // C RunTime Header Files
      #include <stdlib.h>
      #include <malloc.h>
      #include <memory.h>
      #include <tchar.h>

      // --Our main additions:
      #include <assert.h>

      #include <mmsystem.h>
      #include <string>
      #include <list>
      #include <queue>
      #include <map>

      #include <atltypes.h> // for CSize, CPoint and CRect - it's all inline.

      // DirectX Includes
      #include <dxstdafx.h>
      #include <d3dx9tex.h>

      // Boost specific includes:
      #include <boost\config.hpp>
      #include <boost\shared_ptr.hpp>
      using boost::shared_ptr;

      // Other includes:
      #include "GameCode2\\Templates.h"
      #include "CONSTANTS.h"
      #include "MACROS.h"

      #endif // _DOTS_WIN32APP_DIRECTX9C_STDAFX_H

      (eh, who care's if it shows my name anymore.)

      If I'm forgetting a much needed code flag/format, my apologies.


      I've cross-checked project settings against the code Mr. Mike has graciously provided (I love your book btw, I can actually say it's something worth it's weight in gold), and I haven't found any additional inconsistencies that would cause problems (I'm not using physics or multiplayer at this point in time).

      So please, if any of you out there have any idea as to why I'm recieving these errors, I'd greatly appreciate some help. :)

      Thanks,
      -HeavyBlade

      The post was edited 3 times, last by HeavyBlade ().

    • Check Your Project Dependencies

      In the TeapotWars project that is described in the book and provided in the source code, the project has dependencies on projects DXUT and GameCode2.

      These two projects build static libraries DXUT.lib and GameCode2.lib before TeapotWars.exe is built.

      For your project, you need to ensure you have the project dependencies and build order set up in a similar fashion if you are using classes from the static libraries.

      Harold
    • Thanks, it NEVER would have occurred to me to do that, at least, in my 10 years programming, I've never had to. Not once, yet for some reason... wait a minute. Joe must be hexing me again. XD

      Your advice did solve the problem, although I still have no idea why, lol. I had to add the following files to my project:

      -atltypes.cpp
      -atltypes.h
      -ZipFile.cpp
      -ZipFile.h
      -CMath.cpp
      -CMath.h
      -CMath_Random.h

      Thanks everyone for your help :)
    • ...ugh. So close, and yet so far..
      for some reason, whenever I run the app, g_pApp refuses to initialize properly. At all. I'm running it with the DXUT lib compiled, and doing seperately the stuff that would be in the other game lib, but there's no difference between the two versions that should cause the lack of initialization. -_-

      once again, any thoughs would be greatly appreciated.
    • I can't really help you with that one (I'd have a few ideas on how to fix it under Linux, though), but if you want to know why you had to add those files, it's simply because otherwise the compiler doesn't compile them. If the compiler doesn't compile them, then there is nothing to link to, and that's where you get linker errors.

      In theory you could just manually add the files to the Makefile instead (which is probably a project setting somewhere), but that's probably not more convenient, at least for such a small amount of files (I should probably consider doing that for Lua, though, since my file list is gigantic right now).
      -Larrik Jaerico

      www.LarrikJ.com
    • Check your dependencies between the separate projects.

      Right click on your main project and choose "Project Dependencies". This governs the order of compilation so that even though it looks like it should work, it doesn't because the stuff that needs things is being compiled before the things exist.
    • There are many places where method GameCodeApp::InitInstance can return false. This method is in file GameCode.cpp.

      Note particularly around lines 240-244. Is the path to GameCode2.zip still correct for your project?

      You have to go through this file line by line to find where it is returning false.

      Harold
    • No, that's not the problem. g_pApp does not construct itself at all - in other words the program crashes because it keeps trying to access the functions through an invalid class pointer. My problem is that I don't know WHY the class ends up as being perpetually NULL instead of calling it's own constructor code.
    • Sounds like the application instance is failing to initialize somewhere - and it shouldn't just continue exectuing with the gApp pointer NULL....

      Perhaps put a breakpoint on the constructor for GApp?

      Hold on a sec - I think I know what's going on here - the application object is supposed to be overloaded with your own application class, and it is supposed to have a global instantiation in your source code. Look at the Teapot application and find this line:

      TeapotWarsGameApp g_TeapotWarsApp;

      There should be something in your application that is similar.

      I'll take my payment in beer form if I'm right!
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I was thinking that the constructor wasn't being called for the GameApp, but it hadn't really occured to me that the global instance would be the constructor call..

      Thanks, Mr.Mike :), that solved the problem. I guess I owe you a beer then, huh? Must be nice never to have to buy your own beers anymore! lol.