Results 1 to 17 of 17

Thread: mutiple defination of 'VARIABLE'

  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default mutiple defination of 'VARIABLE'

    in all .h files there are #ifndef and #define macros even though i am getting multiple definition.
    only few errors i copied here

    how to solve this problem,


    /home/pavan/Desktop/project/ddmsg/CMessanger.cpp:16: multiple definition of `theView'
    .obj/main.o:/home/pavan/Desktop/project/ddmsg/CBoradCastAddr.cpp:18: first defined here
    .obj/CUDPServer.o: In function `QList<QString>::size() const':
    /home/pavan/Desktop/project/ddmsg/CUDPServer.cpp:13: multiple definition of `g_vAliveHosts'
    .obj/CMessanger.o:/home/pavan/Desktop/project/ddmsg/CMessanger.cpp:16: first defined here
    .obj/CUDPServer.o: In function `QList<QString>::size() const':
    /home/pavan/Desktop/project/ddmsg/CUDPServer.cpp:13: multiple definition of `strSourceHost'
    .obj/CMessanger.o:/home/pavan/Desktop/project/ddmsg/CMessanger.cpp:18: first defined here
    .obj/CUDPServer.o: In function `QList<QString>::size() const':
    /home/pavan/Desktop/project/ddmsg/CUDPServer.cpp:13: multiple definition of `theView'
    .obj/main.o:/home/pavan/Desktop/project/ddmsg/CBoradCastAddr.cpp:18: first defined here
    .obj/CUDPServer.o: In function `QString:perator+=(char)':
    /home/pavan/Desktop/project/ddmsg/CUDPServer.cpp:13: multiple definition of `hostDetmap'
    .obj/CMessanger.o:/home/pavan/Desktop/project/ddmsg/CMessanger.cpp:18: first defined here
    .obj/CUDPServer.o: In function `QString:perator+=(char)':

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Include your variables inside cpp file.

  3. #3
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Quote Originally Posted by saman_artorious View Post
    Include your variables inside cpp file.
    it's not working getting same errors

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mutiple defination of 'VARIABLE'

    Post your CMessanger.cpp:16 and CBoradCastAddr.cpp:18.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Quote Originally Posted by wysota View Post
    Post your CMessanger.cpp:16 and CBoradCastAddr.cpp:18.
    i attached CMessanger.cpp && CBoardCastAddr.cpp files please view atttachments
    Attached Files Attached Files

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,594
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mutiple defination of 'VARIABLE'

    So the two lines the message refers to are:
    Qt Code:
    1. // line 16 of CMessanger.cpp
    2. CMessanger::~CMessanger()
    3. // and line 18 of CBoradCastAddr.cpp‎
    4. {
    To copy to clipboard, switch view to plain text mode 
    Those lines don't actually mention "theView", only one of the files uses "theView", and neither declares "theView". Seems the source you posted doesn't come close to matching the error messages.

  7. #7
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Quote Originally Posted by ChrisW67 View Post
    So the two lines the message refers to are:
    Qt Code:
    1. // line 16 of CMessanger.cpp
    2. CMessanger::~CMessanger()
    3. // and line 18 of CBoradCastAddr.cpp‎
    4. {
    To copy to clipboard, switch view to plain text mode 
    Those lines don't actually mention "theView", only one of the files uses "theView", and neither declares "theView". Seems the source you posted doesn't come close to matching the error messages.
    once again please view these file(different one's), may you can find the error here
    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,594
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mutiple defination of 'VARIABLE'

    The files still do not match the error messages you originally posted. The actual message you get when you compile the actual source code tells you what the error is and where it occurs. We cannot help you specifically unless you provide the errors and the source that generated them.

  9. #9
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Quote Originally Posted by ChrisW67 View Post
    The files still do not match the error messages you originally posted. The actual message you get when you compile the actual source code tells you what the error is and where it occurs. We cannot help you specifically unless you provide the errors and the source that generated them.
    i want to send my project by is more than 1 Mib how to send...

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mutiple defination of 'VARIABLE'

    We just need you to post the content of line #16 of file CMessanger.cpp and line #18 of file CBoardCastAddr.cpp. I don't think those two lines are >1MB large so you can easily paste them inline in your post.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Nov 2012
    Location
    Coimbatore
    Posts
    53
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    Check the multiple definition variables has been defined and declared in your .h files and .cpp files

  12. #12
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Post Re: mutiple defination of 'VARIABLE'

    Quote Originally Posted by wysota View Post
    We just need you to post the content of line #16 of file CMessanger.cpp and line #18 of file CBoardCastAddr.cpp. I don't think those two lines are >1MB large so you can easily paste them inline in your post.
    i am posting my entire error messages in error.txt file in attachments along with other files please view attachments ,may be this error.txt file will help you
    Attached Files Attached Files

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mutiple defination of 'VARIABLE'

    One of the errors refers to main.cpp:19 which is... empty. So again, that's not the code that's failing. Post your real code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,594
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mutiple defination of 'VARIABLE'

    Since matching the code to the errors seems to be a major issue for you, tell us, of all the files in your program which ones create a variable called g_vAliveHosts. CMessanger.cpp is one, but there is more than one. Armed with that knowledge, how do you think your program could get multiple instances of that variable when all the compiled source files are put together?
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  15. #15
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mutiple defination of 'VARIABLE'

    now i will post all files, so you can come across errors ---- i will send all my files in 5 posts please view all 5 posts attachments

    post 1

    ppost 1 follows post 2 please view attachmnets

    .......................


    Added after 4 minutes:


    unzip CMessange.ui.h

    . . . . . . .

    i posted all files please put ui_CViewMessage.h ,ui_CMessanger.h , CMessanger.h,CViewMessage.h in .ui(hiden folder) folder


    Added after 6 minutes:


    actually htis proj is in qt3 i convwerted it inti qt4, after converting i facing these problems
    Attached Files Attached Files
    Last edited by narlapavan; 1st July 2013 at 03:17.

  16. #16
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,594
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mutiple defination of 'VARIABLE'

    Paris_Tuileries_Garden_Facepalm_statue.jpg
    Do a clean build of your program, read your error messages, and think about what they are telling you.
    I don't want all your files, or even the subset you have just given us. It is your job to debug your program.

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: mutiple defination of 'VARIABLE'

    I suggest you start a new project (non-Qt if you have enough skills to do that), add a header (.h) file to it, declare a variable there, add two source (.cpp) files to the project and make both include that header file and try to build the project. Then think why you get the messages you get. After you do that please think if "Qt Programming" forum is really the best place to post your problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. wait until a variable is set
    By kevindebb in forum Qt Programming
    Replies: 4
    Last Post: 7th May 2012, 06:03
  2. QTcpSocket Chat : Mutiple Client using FD_SET and select()
    By cooler123 in forum Qt Programming
    Replies: 20
    Last Post: 15th January 2012, 19:57
  3. variable
    By Atuti2009 in forum Qt Programming
    Replies: 8
    Last Post: 18th November 2009, 09:04
  4. multiple defination
    By phillip_Qt in forum Qt Programming
    Replies: 4
    Last Post: 13th December 2007, 17:32
  5. AVOIDING mutiple inclusion of header file???
    By pratik in forum General Programming
    Replies: 4
    Last Post: 10th July 2007, 14:09

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.