Problem with linking in Borland Builder C++ 5

Discussion in 'C++' started by Dariusz Plygawko, Jul 11, 2003.

  1. 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
     
    Dariusz Plygawko, Jul 11, 2003
    #1
    1. Advertising

  2. "Dariusz Plygawko" <> wrote in message
    news:belu0o$13t$...
    > 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
     
    Josephine Schafer, Jul 11, 2003
    #2
    1. Advertising

  3. > >
    > 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
     
    John Harrison, Jul 11, 2003
    #3
  4. Thank You! :)
     
    Dariusz Plygawko, Jul 11, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. W. McCall
    Replies:
    1
    Views:
    2,342
    Martijn Lievaart
    Feb 6, 2004
  2. Alex@L
    Replies:
    6
    Views:
    482
    Mike Wahler
    Jan 20, 2005
  3. Replies:
    3
    Views:
    1,074
    Robert Emmons
    Jan 24, 2005
  4. Serge Skorokhodov (216716244)

    exception handling problem in Borland C++ Builder 6 (BCB 5.6)

    Serge Skorokhodov (216716244), Apr 10, 2005, in forum: C++
    Replies:
    11
    Views:
    9,207
    Serge Skorokhodov (216716244)
    Apr 11, 2005
  5. iwl
    Replies:
    1
    Views:
    281
    red floyd
    Mar 26, 2007
Loading...

Share This Page