Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > unresolved external

Reply
Thread Tools

unresolved external

 
 
Mark
Guest
Posts: n/a
 
      12-12-2005
I'm trying to write an RAS class on windows ad RasDial's callback
function requires it to either not be a class member or for it to be
static. I went for the static option so in the header file I declared an
extern variable for the class outside of the class definition so I
could use it in the static function, like so:

#ifndef RasClientH
#define RasClientH

#include <ras.h>
#include <raserror.h>

class RasClient
{
[snip]
};

extern RasClient ras;

#endif

then in the header file for the class I will be using ras in I put:

#ifndef MainFormH
#define MainFormH

#include "RasClient.h"

[snip]

class TfrmMain : public TForm
{
[snip]
private: // User declarations
RasClient ras;
[snip]
};

#endif

but when it's linking I'm getting an error saying '[Linker Error]
Unresolved external '_ras' referenced from RASCLIENT.OBJ'. Can anyone
tell me what I'm doing wrong?

TIA
 
Reply With Quote
 
 
 
 
Stephan Hoffmann
Guest
Posts: n/a
 
      12-12-2005
Mark wrote:

> I'm trying to write an RAS class on windows ad RasDial's callback
> function requires it to either not be a class member or for it to be
> static. I went for the static option so in the header file I declared an
> extern variable for the class outside of the class definition so I
> could use it in the static function, like so:
>
> #ifndef RasClientH
> #define RasClientH
>
> #include <ras.h>
> #include <raserror.h>
>
> class RasClient
> {
> [snip]
> };
>
> extern RasClient ras;
>

This extern declaration tells the compiler that a global object
with name ras exists. It does not define (instantiate) it.
You do not instantiate it anywhere in the code you showed.
Just add

RasClient ras;

in one of your implementation files. That should solve your linker
problem, but I'm not sure it's really what you want to do.

Stephan



 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      12-12-2005
Stephan Hoffmann wrote:
> This extern declaration tells the compiler that a global object
> with name ras exists. It does not define (instantiate) it.
> You do not instantiate it anywhere in the code you showed.

[snip]

So declare it outside of a class definition?

Mark
 
Reply With Quote
 
Peter_Julian
Guest
Posts: n/a
 
      12-12-2005

"Mark" <(E-Mail Removed)> wrote in message
news:439ce638$(E-Mail Removed)...
| Stephan Hoffmann wrote:
| > This extern declaration tells the compiler that a global object
| > with name ras exists. It does not define (instantiate) it.
| > You do not instantiate it anywhere in the code you showed.
| [snip]
|
| So declare it outside of a class definition?
|
| Mark

No, define it outside the class definition.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unresolved external symbol/using an external dll Scott Allen C++ 8 05-02-2004 06:11 PM
Linking errors. - VC++ - Unresolved external Symbol mp C++ 2 12-12-2003 06:21 PM
"unresolved external symbol" error in MSVC++ 6.0 Rodolphe C++ 4 10-03-2003 09:44 AM
error LNK2001: unresolved external symbol _IID_IDirectDraw7 Izak Pretorius C++ 2 09-14-2003 11:18 AM
Re: unresolved external symbol error. Need help! John Harrison C++ 0 07-20-2003 07:18 PM



Advertisments