variables & method naming conflicts

Discussion in 'C++' started by Joseph, Feb 27, 2006.

  1. Joseph

    Joseph Guest

    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!
    Joseph, Feb 27, 2006
    #1
    1. Advertising

  2. Joseph

    Rolf Magnus Guest

    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?
    Rolf Magnus, Feb 27, 2006
    #2
    1. Advertising

  3. Joseph

    JE Guest

    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
    JE, Feb 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. helena

    naming variables in code

    helena, Jan 23, 2005, in forum: Java
    Replies:
    6
    Views:
    360
    Collin VanDyck
    Jan 24, 2005
  2. sagejoshua
    Replies:
    16
    Views:
    646
    Michael Winter
    Nov 9, 2005
  3. sb1

    xsl naming variables

    sb1, May 7, 2004, in forum: XML
    Replies:
    2
    Views:
    359
    Andy Fish
    May 7, 2004
  4. Darrel
    Replies:
    2
    Views:
    1,165
    Darrel
    May 17, 2006
  5. Harman
    Replies:
    1
    Views:
    2,489
    Moiristo
    Jul 28, 2006
Loading...

Share This Page