PDA

View Full Version : mutiple defination of 'VARIABLE'



narlapavan
29th June 2013, 18:41
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::operator+=(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::operator+=(char)':

saman_artorious
29th June 2013, 18:55
Include your variables inside cpp file.

narlapavan
29th June 2013, 19:49
Include your variables inside cpp file.

it's not working getting same errors

wysota
29th June 2013, 21:13
Post your CMessanger.cpp:16 and CBoradCastAddr.cpp:18.

narlapavan
30th June 2013, 07:44
Post your CMessanger.cpp:16 and CBoradCastAddr.cpp:18.
i attached CMessanger.cpp && CBoardCastAddr.cpp files please view atttachments

ChrisW67
30th June 2013, 09:12
So the two lines the message refers to are:


// line 16 of CMessanger.cpp
CMessanger::~CMessanger()
// and line 18 of CBoradCastAddr.cpp‎
{

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.

narlapavan
30th June 2013, 11:06
So the two lines the message refers to are:


// line 16 of CMessanger.cpp
CMessanger::~CMessanger()
// and line 18 of CBoradCastAddr.cpp‎
{

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

ChrisW67
30th June 2013, 11:27
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.

narlapavan
30th June 2013, 14:38
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...

wysota
30th June 2013, 16:55
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.

mania
30th June 2013, 17:59
Check the multiple definition variables has been defined and declared in your .h files and .cpp files

narlapavan
30th June 2013, 18:28
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

wysota
30th June 2013, 19:01
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.

ChrisW67
30th June 2013, 23:18
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?

narlapavan
1st July 2013, 04:17
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

ChrisW67
1st July 2013, 05:30
9255
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.

wysota
1st July 2013, 08:18
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.