Problem with linking in Borland Builder C++ 5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dariusz Plygawko

    Problem with linking in Borland Builder C++ 5

    Welcome,
    When I'am trying to call static function(setAre aLoader) 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\NAVIGA TOR\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(A reaLoader * p_loader);
    static Area * createAreaWithL oader(AnsiStrin g p_areaId);
    static AreaLoader * m_loader;
    };
    #endif

    ***area.cpp:***

    #include "Area.h"

    ....

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

    ....

    Best Regards,
    Dariusz


  • Josephine Schafer

    #2
    Re: Problem with linking in Borland Builder C++ 5


    "Dariusz Plygawko" <Dariusz.Plygaw ko@cern.ch> wrote in message
    news:belu0o$13t $1@sunnews.cern .ch...[color=blue]
    > Welcome,
    > When I'am trying to call static function(setAre aLoader) from other class,[/color]
    I[color=blue]
    > get following linker-error. How to solve it? I'm slowly getting crazy...[/color]
    And[color=blue]
    > I have the same problem with the rest of static members... Help me!
    >
    > [Linker Error] Unresolved external 'Area::m_loader ' referenced from
    > C:\DAREK\NAVIGA TOR\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(A reaLoader * p_loader);
    > static Area * createAreaWithL oader(AnsiStrin g p_areaId);
    > static AreaLoader * m_loader;
    > };
    > #endif
    >
    > ***area.cpp:***
    >
    > #include "Area.h"
    >
    > ...
    >
    > void Area::setAreaLo ader(AreaLoader * p_loader)
    > {
    > m_loader = p_loader;
    > }
    >[/color]
    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::setAreaLo ader without defining it, so you
    know why you are getting the linker error.

    --
    With best wishes,
    J.Schafer


    Comment

    • John Harrison

      #3
      Re: Problem with linking in Borland Builder C++ 5

      > >[color=blue]
      > 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[/color]

      Actually like this

      AreaLoader* Area::m_loader = ...;

      john


      Comment

      • Dariusz Plygawko

        #4
        Re: Problem with linking in Borland Builder C++ 5

        Thank You! :)


        Comment

        Working...