Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > variables & method naming conflicts

Reply
Thread Tools

variables & method naming conflicts

 
 
Joseph
Guest
Posts: n/a
 
      02-27-2006
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!

 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      02-27-2006
Joseph wrote:

> 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?

 
Reply With Quote
 
 
 
 
JE
Guest
Posts: n/a
 
      02-27-2006

Joseph wrote:
<snip>
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Javax.naming Exception: name not found in naming service. Harman Java 1 07-28-2006 08:51 AM
Using public shared variables...asking for trouble with thread conflicts? Darrel ASP .Net 2 05-17-2006 02:44 AM
Help with Javascript: naming variables using other variables sagejoshua HTML 16 11-09-2005 12:27 PM



Advertisments