Results 1 to 4 of 4

Thread: Extern Variable linkage error

  1. #1
    Join Date
    Jan 2011
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Extern Variable linkage error

    in my Qt project i have a QString variable in one class(variable is gloablly defined in dialog1.cpp)

    QString d;

    i am trying to access the same variable from another class (variable is declared as extern in timeall.cpp)

    extern QString d;

    Wen i compile the file, there appears to be a linker error

    collect2: ld returned 1 exit status

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Extern Variable linkage error

    can you please post the actual error message.

  3. #3
    Join Date
    Jan 2011
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Extern Variable linkage error

    here is the compile output

    collect2: ld returned 1 exit status
    make: Leaving directory `/root/Desktop/deep (copy)'
    make: *** [UNI] Error 1
    Exited with code 2.
    Error while building project UNI
    When executing build step 'Make'

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Extern Variable linkage error

    in my Qt project i have a QString variable in one class(variable is gloablly defined in dialog1.cpp)

    QString d;
    Can you show the code surrounding this declaration?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Variable not declared in this scope error
    By hojoff79 in forum Newbie
    Replies: 1
    Last Post: 30th December 2010, 00:29
  2. Static linkage of the library
    By Sergei Smirnov in forum Qt Programming
    Replies: 0
    Last Post: 22nd June 2010, 18:17
  3. Conditional linkage
    By TorAn in forum General Programming
    Replies: 1
    Last Post: 22nd December 2009, 21:10
  4. error variable not declared
    By aj2903 in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2008, 15:58
  5. Replies: 1
    Last Post: 4th September 2008, 14:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.