×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    2

    undefined symbol, link problem. Please help

    EDIT: fixed, thanks for help.

    I get this when I try to make the project.
    Errors caused tool to abort.
    Link Error : Undefined symbol: 'CMyCompoundClass::CMyCompoundClass(void) (??0CMyCompoundClass@@QAE@XZ)'
    Link Error : referenced from 'class CMyCompoundClass * CMyCompoundClass::NewL(void) (?NewL@CMyCompoundClass@@SAPAV1@XZ)' in CMyCompoundClass.cpp:19
    Link Error : Undefined symbol: 'CMySimpleClass::CMySimpleClass(void) (??0CMySimpleClass@@QAE@XZ)'
    Link Error : referenced from 'class CMySimpleClass * CMySimpleClass::NewL(void) (?NewL@CMySimpleClass@@SAPAV1@XZ)' in CMySimpleClass.cpp:17
    Link Error : Link failed

    I found some answers to this problem but still dont know how to fix it, so if someone could help.

    My code is following:

    #include "CMySimpleClass.h"
    void CMySimpleClass::ConstructL()
    {
    iMember = 0;
    }

    CMySimpleClass* CMySimpleClass::NewLC()
    {
    CMySimpleClass *self= new (ELeave) CMySimpleClass;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    CMySimpleClass* CMySimpleClass::NewL()
    {
    CMySimpleClass *self = new (ELeave) CMySimpleClass;
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

    TInt CMySimpleClass::Get()
    {
    return iMember;
    }

    void CMySimpleClass::AddInt(TInt aValue)
    {
    iMember = iMember + aValue;
    }


    ###################################################


    #ifndef CMySimpleClass_H
    #define CMySimpleClass_H
    #include <e32base.h>
    class CMySimpleClassublic CBase
    {
    public:
    CMySimpleClass();
    ~CMySimpleClass();
    void AddInt(TInt aValue);
    TInt Get();
    static CMySimpleClass* NewL();
    static CMySimpleClass* NewLC();
    void ConstructL();
    private:

    TInt iMember;

    };

    #endif


    ###################################################


    #include "CMyCompoundClass.h"

    void CMyCompoundClass::ConstructL()
    {
    iSimpleClass = CMySimpleClass :: NewL();
    iSimpleClass->AddInt(5);
    }

    CMyCompoundClass* CMyCompoundClass::NewLC()
    {
    CMyCompoundClass* self= new (ELeave) CMyCompoundClass;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    CMyCompoundClass* CMyCompoundClass::NewL()
    {
    CMyCompoundClass *self = new (ELeave) CMyCompoundClass;
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

    TInt CMyCompoundClass::Get()
    {
    return iSimpleClass->Get();
    }

    void CMyCompoundClass::AddInt()
    {
    iSimpleClass->AddInt(5);
    }


    ###################################################


    #include <e32base.h>
    #include "CMySimpleClass.h"
    class CMyCompoundClassublic CBase
    {
    public:
    CMyCompoundClass();
    ~CMyCompoundClass();
    void AddInt();
    TInt Get();
    static CMyCompoundClass* NewL();
    static CMyCompoundClass* NewLC();
    void ConstructL();
    private:

    CMySimpleClass *iSimpleClass;

    };


    /* Copyright (c) 2004, Nokia. All rights reserved */


    ###################################################


    // INCLUDE FILES
    #include <coemain.h>
    #include "HelloWorldBasicAppView.h"


    // ============================ MEMBER FUNCTIONS ===============================

    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView::NewL()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewL( const TRect& aRect )
    {
    CHelloWorldBasicAppView* self = CHelloWorldBasicAppView::NewLC( aRect );
    CleanupStack::Pop( self );
    return self;
    }

    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView::NewLC()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewLC( const TRect& aRect )
    {
    CHelloWorldBasicAppView* self = new ( ELeave ) CHelloWorldBasicAppView;
    CleanupStack::PushL( self );
    self->ConstructL( aRect );
    return self;
    }

    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView::ConstructL()
    // Symbian 2nd phase constructor can leave.
    // -----------------------------------------------------------------------------
    //
    void CHelloWorldBasicAppView::ConstructL( const TRect& aRect )
    {
    // Create a window for this application view
    CreateWindowL();

    // Set the windows size
    SetRect( aRect );
    iCompoundClass = CMyCompoundClass :: NewL();

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView::CHelloWorldBasicAppView()
    // C++ default constructor can NOT contain any code, that might leave.
    // -----------------------------------------------------------------------------
    //
    CHelloWorldBasicAppView::CHelloWorldBasicAppView()
    {
    // No implementation required
    }


    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
    // Destructor.
    // -----------------------------------------------------------------------------
    //
    CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
    {
    // No implementation required
    delete iCompoundClass;
    }


    // -----------------------------------------------------------------------------
    // CHelloWorldBasicAppView:raw()
    // Draws the display.
    // -----------------------------------------------------------------------------
    //
    void CHelloWorldBasicAppView:raw( const TRect& /*aRect*/ ) const
    {
    // Get the standard graphics context
    CWindowGc& gc = SystemGc();

    // Gets the control's extent
    TRect rect = Rect();


    // to the Draw-method:

    // get the number
    TInt number=iCompoundClass->Get();

    // create a descriptor and copy the number into it
    TBuf<32> numAsText;
    numAsText.Num(number); // convert the number to the text


    // write the text to the display
    gc.UseFont(iCoeEnv->NormalFont());

    gc.DrawText(numAsText, TPoint(10,40));
    gc.DiscardFont();

    ResetGc();

    // Clears the screen
    gc.Clear( rect );
    }

    // End of File

    /* Copyright (c) 2004, Nokia. All rights reserved */


    ###################################################


    #ifndef __HELLOWORLDBASICAPPVIEW_H__
    #define __HELLOWORLDBASICAPPVIEW_H__

    // INCLUDES
    #include <coecntrl.h>
    #include "CMyCompoundClass.h"

    // CLASS DECLARATION
    class CEikLabel;
    class CHelloWorldBasicAppView : public CCoeControl
    {
    public: // New methods

    /**
    * NewL.
    * Two-phased constructor.
    * Create a CHelloWorldBasicAppView object, which will draw itself to aRect.
    * @param aRect The rectangle this view will be drawn to.
    * @return a pointer to the created instance of CHelloWorldBasicAppView.
    */
    static CHelloWorldBasicAppView* NewL( const TRect& aRect );

    /**
    * NewLC.
    * Two-phased constructor.
    * Create a CHelloWorldBasicAppView object, which will draw itself
    * to aRect.
    * @param aRect Rectangle this view will be drawn to.
    * @return A pointer to the created instance of CHelloWorldBasicAppView.
    */
    static CHelloWorldBasicAppView* NewLC( const TRect& aRect );

    /**
    * ~CHelloWorldBasicAppView
    * Virtual Destructor.
    */
    virtual ~CHelloWorldBasicAppView();
    void ConstructL(const TRect& aRect);

    public: // Functions from base classes

    /**
    * From CCoeControl, Draw
    * Draw this CAnimationAppView to the screen.
    * @param aRect the rectangle of this view that needs updating
    */
    void Draw( const TRect& aRect ) const;

    private: // Constructors

    /**
    * ConstructL
    * 2nd phase constructor.
    * Perform the second phase construction of a
    * CHelloWorldBasicAppView object.
    * @param aRect The rectangle this view will be drawn to.
    */


    /**
    * CHelloWorldBasicAppView.
    * C++ default constructor.
    */
    CHelloWorldBasicAppView();
    // CEikLabel* iLabel; // example label
    // CEikLabel* iMyLabel; // added 4.9
    // CEikLabel* iToDoLabel; // example label
    CMyCompoundClass* iCompoundClass;

    };

    #endif // __HELLOWORLDBASICAPPVIEW_H__

    // End of File


    There is all the code, can someone say what am I doing wrong?
    Last edited by Gride; 2006-12-11 at 09:46.

  2. #2
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: undefined symbol, link problem. Please help

    Hi,

    You have not implemented default constructor in your CMyCompoundClass.

    regards,
    eswar

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    2

    thank you

    Thank you Eswar, that was it...
    Very shamed about the rookie/newbie mistake =)

  4. #4
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    140

    Re: undefined symbol, link problem. Please help

    I am having a similar issue, i am trying to follow the view server example on the NewLC website and have made all the necessary changes but get the following link errors when I compile the code:


    Undefined symbol: 'int CFont::AscentInPixels(void) const (?AscentInPixels@CFont@@QBEHXZ)' referenced from 'void CClientSideAppView:raw(class TRect const &) const (?Draw@CClientSideAppView@@UBEXABVTRect@@@Z)' in ClientSideAppView.cpp:111

    Undefined symbol: 'int CFont::TextWidthInPixels(class TDesC16 const &) const (?TextWidthInPixels@CFont@@QBEHABVTDesC16@@@Z)' referenced from 'void CClientSideAppView:raw(class TRect const &) const (?Draw@CClientSideAppView@@UBEXABVTRect@@@Z)' in ClientSideAppView.cpp:103 referenced from 'void CClientSideAppView:raw(class TRect const &) const (?Draw@CClientSideAppView@@UBEXABVTRect@@@Z)' in ClientSideAppView.cpp:110

    Undefined symbol: 'void RWindowTreeNode::SetOrdinalPosition(int) (?SetOrdinalPosition@RWindowTreeNode@@QAEXH@Z)' referenced from 'void CClientSideAppView::ViewActivatedL(class TVwsViewId const &, class TUid, class TDesC8 const &) (?ViewActivatedL@CClientSideAppView@@EAEXABVTVwsViewId@@VTUid@@ABVTDesC8@@@Z)' in ClientSideAppView.cpp:141

    I'm having trouble understanding the problem, have I left out a needed header file or something?

    Here is the relevant function for reference:

    void CClientSideAppView:raw(const TRect& /*aRect*/) const
    {
    _LIT(KTitle,"ClientSide App");
    _LIT(KCredit,"Nigel");

    CWindowGc& gc = SystemGc(); // Window graphics context
    TRect rect = Rect(); // Area in which we shall draw
    TPoint point(0,0);
    const CFont* font = iEikonEnv->NormalFont();
    gc.SetBrushColor(KRgbBlack);
    gc.Clear(); // Start with a clear screen
    gc.SetPenColor(KRgbWhite);
    gc.UseFont(font);

    point.iX = rect.Width()/2 - font->TextWidthInPixels(KTitle)/2;
    point.iY = rect.Height()/2;

    gc.DrawText(KTitle, point);
    gc.DiscardFont();
    font = iEikonEnv->AnnotationFont();

    point.iX = rect.Width()/2 - font->TextWidthInPixels(KCredit)/2;
    point.iY = font->AscentInPixels() + 10;

    gc.UseFont(font);
    gc.DrawText(KCredit, point);
    gc.DiscardFont();
    }
    Last edited by NigelT; 2006-12-21 at 17:04.

  5. #5
    Super Contributor
    Join Date
    May 2003
    Location
    Vancouver, Canada
    Posts
    985

    Re: undefined symbol, link problem. Please help

    Have you included gdi.lib and ws32.lib in your .mmp file?
    Or, if you are using Carbide.c++, have you added them in the Project Properties? It seems that they are missing from your project file.

    Antony

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: undefined symbol, link problem. Please help

    You have not mentioned the SDK you use. Note that implementation of CFont has been moved to gdi.lib starting from S60 3rd edition.

    Edit: sorry Antony, somehow I haven't noticed the gdi.lib in your post at the first read.

  7. #7
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    140

    Re: undefined symbol, link problem. Please help

    I have included my SDK and IDE in my sig (should have done this before).
    I have both gdi.lib and ws32.lib in my .mmp file, but have not added them to my project properties. Could you explain this please, how do I add these .lib files to my project properties?
    SDK: S60 3rd Edition MR
    IDE: Carbide.C++ Express v1.1

  8. #8
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    140

    Re: undefined symbol, link problem. Please help

    I have just found this out.

    But why do I have to do this for Carbide? Why is not enough to include them in the .mmp file?
    SDK: S60 3rd Edition MR
    IDE: Carbide.C++ Express v1.1

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: undefined symbol, link problem. Please help

    Carbide.c++ does not use the .mmp file. It can import it, but it is a one-time action.
    As I remember, if you generate a new project with Carbide.c++ it will have no .mmp at all.

  10. #10
    Super Contributor
    Join Date
    May 2003
    Location
    Vancouver, Canada
    Posts
    985

    Re: undefined symbol, link problem. Please help

    wizard_hu is right, you have to do it from Project Properties because Carbide.c++ doesn't process .mmp file.

    One more thing to remember, you have to add those libraries in all targets, e.g. WINSCW, GCCE. Adding in one target will not add them in other targets.

    Antony

Similar Threads

  1. Fail to build syexpat 1.3 under 2nd FP3
    By harry_zhang in forum Symbian
    Replies: 10
    Last Post: 2010-03-19, 10:24
  2. SyExpat + problem + memmove + Carbide Express
    By pearman in forum Symbian
    Replies: 2
    Last Post: 2006-10-14, 22:21
  3. Whats missing?
    By imrank in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-08-28, 07:22
  4. 21 errors in j2me , help in soving them
    By abhishek_1211 in forum General Messaging
    Replies: 0
    Last Post: 2006-04-01, 09:04
  5. Help me : unresolved external symbol
    By hovannhan in forum Symbian
    Replies: 2
    Last Post: 2005-02-20, 11:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×