C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

variables & method naming conflicts

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Joseph
Guest





PostPosted: Mon Feb 27, 2006 3:06 pm    Post subject: variables & method naming conflicts Reply with quote



Hi Gurus,
I got a problem, I am trying to port a win32 prog to Linux. It was all
one big program.cpp and I have to split the functions into separate
init_pxi6052e.cpp,func1.cpp and func2.cpp in order to compile them
separately and debug them. In both cpp file I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp". Both these object
compiles ok. SEe here
%g++ -c test_init_boards.cpp
%g++ -c init_pxi6052e.cpp
However it screws up where I try to link them together to an
executable.

%g++ -o test_init_boards test_init_boards.o init_pxi6052e.o
callback_everyn.o -lnidaqmx


init_pxi6052e.o(.bss+0x20): multiple definition of `InputDataBuffer'
test_init_boards.o(.bss+0x20): first defined here
init_pxi6052e.o(.bss+0x24): multiple definition of `OutputDataBuffer'
test_init_boards.o(.bss+0x24): first defined here
init_pxi6052e.o(.bss+0x40): multiple definition of `msg'
test_init_boards.o(.bss+0x40): first defined here
.... [many lines more here]

I am mixing some C header files in the "datatype.h" files. What is the
best ways to handle this? Please help!
Back to top
Rolf Magnus
Guest





PostPosted: Mon Feb 27, 2006 3:06 pm    Post subject: Re: variables & method naming conflicts Reply with quote



Joseph wrote:

Quote:
Hi Gurus,
I got a problem, I am trying to port a win32 prog to Linux. It was all
one big program.cpp and I have to split the functions into separate
init_pxi6052e.cpp,func1.cpp and func2.cpp in order to compile them
separately and debug them. In both cpp file I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp". Both these object
compiles ok. SEe here
%g++ -c test_init_boards.cpp
%g++ -c init_pxi6052e.cpp
However it screws up where I try to link them together to an
executable.

%g++ -o test_init_boards test_init_boards.o init_pxi6052e.o
callback_everyn.o -lnidaqmx


init_pxi6052e.o(.bss+0x20): multiple definition of `InputDataBuffer'
test_init_boards.o(.bss+0x20): first defined here
init_pxi6052e.o(.bss+0x24): multiple definition of `OutputDataBuffer'
test_init_boards.o(.bss+0x24): first defined here
init_pxi6052e.o(.bss+0x40): multiple definition of `msg'
test_init_boards.o(.bss+0x40): first defined here
... [many lines more here]

I am mixing some C header files in the "datatype.h" files. What is the
best ways to handle this? Please help!

What are InputDataBuffer, OutputDataBuffer and msg? Are they types? Global
variables? Where are they defined? In the cpp files or in the header? Where
is their declaration?
Back to top
JE
Guest





PostPosted: Mon Feb 27, 2006 5:06 pm    Post subject: Re: variables & method naming conflicts Reply with quote



Joseph wrote:
<snip>
Quote:
I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp".
snip
multiple definition of
snip whatever


Maybe you've got globals that violate the "One Definition Rule" in
header(s)? Make sure you've got extern whatever in the header (_not_
initialized, because that would be a definition) for your declaration,
and _one_ definition in one of your .cpp files...

JE
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.