By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

unresolved external

P: n/a
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
Dec 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Dec 12 '05 #2

P: n/a
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
Dec 12 '05 #3

P: n/a

"Mark" <us**@site.com> wrote in message
news:43********@news.comindico.com.au...
| 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.
Dec 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.