• Welcome to Valhalla Legends Archive.
 

unresolved external symbols?!

Started by UserLoser., April 13, 2004, 09:04 PM

Previous topic - Next topic

UserLoser.

I'm starting a Battle.net client in C++ that loads multiple profiles per exe, and I'm having some trouble with a class I'm starting which I believe will control each profile that's being ran.  I'm getting about 12 unresolved external symbols.  I've tried many things such as search google, ask others on MSN, and nobody said they know what's wrong.  

Quote
GUI.OBJ : error LNK2001: unresolved external symbol "public: static class BNCSClient * GUI::BNCS" (?BNCS@GUI@@2PAVBNCSClient@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static char * GUI::Profile" (?Profile@GUI@@2PADA)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static class RICHTEXTBOX * GUI::rtb" (?rtb@GUI@@2PAVRICHTEXTBOX@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static class CONFIGURATION * GUI::conf" (?conf@GUI@@2PAVCONFIGURATION@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static char * GUI::RegistryPath" (?RegistryPath@GUI@@2PADA)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static class Registry * GUI::reg" (?reg@GUI@@2PAVRegistry@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static struct HICON__ * GUI::icon" (?icon@GUI@@2PAUHICON__@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static struct HINSTANCE__ * GUI::hAppInstance" (?hAppInstance@GUI@@2PAUHINSTANCE__@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static struct BOTSTATEINFORMATION * GUI::bstate" (?bstate@GUI@@2PAUBOTSTATEINFORMATION@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static struct PROFILEUSER * GUI::puser" (?puser@GUI@@2PAUPROFILEUSER@@A)
GUI.OBJ : error LNK2001: unresolved external symbol "public: static struct BOTNETCONFIGURATION * GUI::bconf" (?bconf@GUI@@2PAUBOTNETCONFIGURATION@@A)
Release/BotUI.dll : fatal error LNK1120: 11 unresolved externals
Well, here's the two main files of the class: GUI.cpp & GUI.h.

If any other files of the DLL source are required, such as the other classes i'll upload the rest too.  Defs.h contains includes to all other files and other definitions.

Any help would be appreciated!

Oh, and crappy c++ coding copyright (C) 2004 - UserLoser

Eibro

#1
You need to initialize your static class variables.
eg. in GUI.cpp

  HINSTANCE GUI::hAppInstance = GetModuleHandle( 0 );
  HICON GUI::icon = NULL;
  char GUI::RegistryPath[256];
  char GUI::Profile[256];

  BNCSClient* GUI::BNCS = NULL;
  RICHTEXTBOX* GUI::rtb = NULL;
  Registry* GUI::reg = NULL;
  CONFIGURATION* GUI::conf = NULL;
  PROFILEUSER* GUI::puser = NULL;
  BOTNETCONFIGURATION* GUI::bconf = NULL;
  BOTSTATEINFORMATION* GUI::bstate = NULL;
Eibro of Yeti Lovers.

UserLoser.


Yoni

A general comment: "unresolved external symbol" means some function or variable is declared, but never defined.

You'll see it when you misspell function names in their definitions, when you include an external library's header file but not the import library (i.e. #include <winsock2.h> without referencing ws2_32.lib), when you compile an executable but don't include a main/WinMain, when you don't define static member variables (your case), and probably in some other cases that don't come to my mind right now...

Adron

You'll see it when you have mismatches in calling conventions (C++/C/name mangling), typically happens when you use a single header file both when compiling the static library and the exe, but different compiler settings.

You'll see it when you declare variables "extern", but then never define them.

UserLoser.

Thanks, I would so +1 all of you :P