Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiling w/ library header files

Status
Not open for further replies.

txjump

Programmer
May 17, 2002
76
0
0
US
Hello all,

I'm trying to create a tool library so i can use several functions in different dll files that im creating. my problem is that i can compile the library fine. but when i do a #include and set the vc++ "additional include directories" w/ the correct path to the header file...i get two compile errors that are for the tool library header file (the one that compiles fine on its own).

c:\Documents and Settings\swaage\My Documents\Visual Studio Projects\systemTools\systemTool.h(31) : error C2143: syntax error : missing ';' before '<'
c:\Documents and Settings\swaage\My Documents\Visual Studio Projects\systemTools\systemTool.h(31) : error C2238: unexpected token(s) preceding ';'

could someone explain to me why this happens? and maybe what i need to do to fix it? :)

thanks,
txjump
 
If your header file(s) mentions any &quot;user-defined&quot; classes which are not defined or #include'd in that header file, then you need to &quot;forward reference&quot; them (without the definition or body) prior to the reference, something like this:
Code:
// this is what's needed in the header:
class COtherClass;

// the class where COtherClass is referenced:
class CThisClass
{
public:
  COtherClass  MyOtherClass;
...
};
 
thanks, but I dont reference any other &quot;user-defined&quot; classes at this point. i will keep that in mind if i do, but for now its just a pretty simple class.

#pragma once
struct {
UINT type; // return code from GetDriveType
LPCSTR name; // ascii name
} DriveTypeFlags [] = {
{ DRIVE_UNKNOWN, &quot;Unknown&quot; },
{ DRIVE_NO_ROOT_DIR, &quot;Invalid path&quot; },
{ DRIVE_REMOVABLE, &quot;Removable&quot; },
{ DRIVE_FIXED, &quot;Fixed&quot; },
{ DRIVE_REMOTE, &quot;Network drive&quot; },
{ DRIVE_CDROM, &quot;CD-ROM&quot; },
{ DRIVE_RAMDISK, &quot;RAM disk&quot; },
{ 0, NULL},
};

class systemTool
{


public:

static CString pathForFoundFile;
static bool found;

systemTool(void);
~systemTool(void);

// returns a double array of strings. each row contains the drive name and type of drive
static map<char*, char*> getMappedDrives(void);
static bool checkEnvVar();
static void findFile(LPCTSTR pstr, CString fileName, CString pathContains);

};


thats the whole .h file. any other suggestions? :S

txjump
 
I believe it doesn't recognize &quot;map&quot; in the following line:
Code:
static map<char*, char*> getMappedDrives(void);
Try adding the following #include near the top of your header file:
Code:
#include <map>

From MSDN:

Include the STL standard header <map> to define the container template classes map and multimap, and their supporting templates.

 
thanks for your replies :)

it is included in the stdafx.h file but i went ahead and included it in the systemTool.h (the header file i posted above).

also tried to put it in my dll that is using the systemTool.h file. neither worked. :( still got the same errors when compiling the dll. systemTool project still compiled fine on its own.

i moved all the includes over to systemTool.h and it compiled on its own. but now when i try from the dll i get two different error messages. it compiles but it doesnt link right because

systemTools.lib(systemTool.obj) : error LNK2001: unresolved external symbol &quot;public: static class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > systemTool::pathForFoundFile2&quot; (?pathForFoundFile2@systemTool@@2V?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@A)

systemTools.lib(systemTool.obj) : error LNK2001: unresolved external symbol &quot;public: static bool systemTool::found2&quot; (?found2@systemTool@@2_NA)

.\Debug/PRLBridgeDll.dll : fatal error LNK1120: 2 unresolved externals

grrrrrrrrrrrrrr! im so confused. why would the dll compile have a resolution problem with two variables in the library? as you can see, i tried renaming things just incase there was a problem there...but same errors. one of them is a simple data type of bool. the other is a CString.

i really wanna do this with a library but i just may copy my code into my next dll (duplicate code, ick).

thanks :)
txjump
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top