Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with linking in Borland Builder C++ 5

Reply
Thread Tools

Problem with linking in Borland Builder C++ 5

 
 
Dariusz Plygawko
Guest
Posts: n/a
 
      07-11-2003
Welcome,
When I'am trying to call static function(setAreaLoader) from other class, I
get following linker-error. How to solve it? I'm slowly getting crazy... And
I have the same problem with the rest of static members... Help me!

[Linker Error] Unresolved external 'Area::m_loader' referenced from
C:\DAREK\NAVIGATOR\AREA.OBJ

***Area.h:***

#ifndef area_H
#define area_H

#include <vcl.h>
#include "Map.h"
#include "AreaLoader.h"

class Area
{

private:
Map * m_maps;
int m_mapsNumber;
public:
Area();
~Area();
static void setAreaLoader(AreaLoader * p_loader);
static Area * createAreaWithLoader(AnsiString p_areaId);
static AreaLoader * m_loader;
};
#endif

***area.cpp:***

#include "Area.h"

....

void Area::setAreaLoader(AreaLoader * p_loader)
{
m_loader = p_loader;
}

....

Best Regards,
Dariusz


 
Reply With Quote
 
 
 
 
Josephine Schafer
Guest
Posts: n/a
 
      07-11-2003

"Dariusz Plygawko" <(E-Mail Removed)> wrote in message
news:belu0o$13t$(E-Mail Removed)...
> Welcome,
> When I'am trying to call static function(setAreaLoader) from other class,

I
> get following linker-error. How to solve it? I'm slowly getting crazy...

And
> I have the same problem with the rest of static members... Help me!
>
> [Linker Error] Unresolved external 'Area::m_loader' referenced from
> C:\DAREK\NAVIGATOR\AREA.OBJ
>
> ***Area.h:***
>
> #ifndef area_H
> #define area_H
>
> #include <vcl.h>
> #include "Map.h"
> #include "AreaLoader.h"
>
> class Area
> {
>
> private:
> Map * m_maps;
> int m_mapsNumber;
> public:
> Area();
> ~Area();
> static void setAreaLoader(AreaLoader * p_loader);
> static Area * createAreaWithLoader(AnsiString p_areaId);
> static AreaLoader * m_loader;
> };
> #endif
>
> ***area.cpp:***
>
> #include "Area.h"
>
> ...
>
> void Area::setAreaLoader(AreaLoader * p_loader)
> {
> m_loader = p_loader;
> }
>

You have just declared Area::m_loader, not defined it.You need to
define it in an implementation file (area.cpp) like
Area::m_loader = .... // define m_loader
You try to access it in Area::setAreaLoader without defining it, so you
know why you are getting the linker error.

--
With best wishes,
J.Schafer


 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      07-11-2003
> >
> You have just declared Area::m_loader, not defined it.You need to
> define it in an implementation file (area.cpp) like
> Area::m_loader = .... // define m_loader


Actually like this

AreaLoader* Area::m_loader = ...;

john


 
Reply With Quote
 
Dariusz Plygawko
Guest
Posts: n/a
 
      07-11-2003
Thank You!


 
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
Borland builder linking binary via resource iwl C++ 1 03-26-2007 05:03 PM
exception handling problem in Borland C++ Builder 6 (BCB 5.6) Serge Skorokhodov (216716244) C++ 11 04-11-2005 07:34 PM
Problem with fast lines in TeeChart v4.04 (Borland c++ builder 6) shuusaku@gmail.com C++ 3 01-24-2005 01:59 PM
Problem with Partial Template Specialization and Borland C++ Builder Alex@L C++ 6 01-20-2005 08:34 PM
Where to ask about Borland C++ Builder Socket/Threading problem? J. W. McCall C++ 1 02-06-2004 09:20 AM



Advertisments