Results 1 to 3 of 3

Thread: multiple definition error - NokiaQtSDK maemo

  1. #1
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default multiple definition error - NokiaQtSDK maemo

    hello,
    i am frustrated with this compiler error, plz have a look to my code attached (click here)and enlighten me.
    i am trying to use the Comms class inside the new.h so when i include comms.h in new.cpp i get erros.
    everything is explained in the new.cpp file if u check the code.
    Thanks in advance

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: multiple definition error - NokiaQtSDK maemo

    That usually happens when you define functions in an header file and include that header in multiple other files (you end-up with that functions having multiple definitions), if this is the case: move the definitions in a cpp file of that class

  3. The following user says thank you to Zlatomir for this useful post:

    raedbenz (21st July 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: multiple definition error - NokiaQtSDK maemo

    Quote Originally Posted by Zlatomir View Post
    That usually happens when you define functions in an header file and include that header in multiple other files (you end-up with that functions having multiple definitions), if this is the case: move the definitions in a cpp file of that class
    Thanks that worked...onemore hint, that i discovered, is that global variables should be defined in .cpp file and then define them as extern in a lets say, share.h header to use them all over the project.

    cheerts

Similar Threads

  1. Multiple definition of a variable?
    By T0bi4s in forum Newbie
    Replies: 5
    Last Post: 14th January 2010, 22:13
  2. Replies: 3
    Last Post: 19th February 2008, 13:10
  3. "Multiple definition of 'gridLayout'"
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 8th January 2008, 20:13
  4. Multiple Definition errors in moc_<Obj>.cpp and moc_<Obj>_obj.cpp
    By Doug Broadwell in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2007, 19:10
  5. Getting multiple definition error from qatomic_x86_64.h
    By markcole in forum General Programming
    Replies: 1
    Last Post: 30th August 2007, 19:39

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.