PLEASE HELP - Linkage problem in gcc 3.2.3 with arbitrary precision arithmetic

Discussion in 'C++' started by cpptutor2000@yahoo.com, Dec 13, 2004.

  1. Guest

    Could some C++ guru please help me? I am using a BigInteger class which
    is really
    a wrapper around a C source file(mpi.c) that does arbitrary precision
    arithmetic operations. When I compile the C file using gcc -g -o mpi
    mpi.c rng.c -lm
    there are NO compilation or linking errors. However, when I try to
    compile the
    C++ wrapper class using g++ -g -o bigint bigint.C mpi.c rng.c -lm, I
    get strange linkage problems that all the functions in the C
    file(mpi.c) are 're-defined'. I have checked over and over, but there
    is no re-definition of the functions. I have not posted the source
    code, as it is fairly huge. Could someone provide some
    ideas as to what might be going wrong? I am using gcc 3.2.3. Thanks in
    advance for your help!
     
    , Dec 13, 2004
    #1
    1. Advertising

  2. Re: PLEASE HELP - Linkage problem in gcc 3.2.3 with arbitrary precisionarithmetic

    wrote:
    > Could some C++ guru please help me? I am using a BigInteger class which
    > is really
    > a wrapper around a C source file(mpi.c) that does arbitrary precision
    > arithmetic operations. When I compile the C file using gcc -g -o mpi
    > mpi.c rng.c -lm
    > there are NO compilation or linking errors. However, when I try to
    > compile the
    > C++ wrapper class using g++ -g -o bigint bigint.C mpi.c rng.c -lm, I
    > get strange linkage problems that all the functions in the C
    > file(mpi.c) are 're-defined'. I have checked over and over, but there
    > is no re-definition of the functions. I have not posted the source
    > code, as it is fairly huge. Could someone provide some
    > ideas as to what might be going wrong? I am using gcc 3.2.3.


    Try

    gcc -Wall -std=c99 -pedantic -c mpi.c rng.c

    then

    g++ -Wall -ansi -pedantic -g -o bigint bigint.C mpi.o rng.o -lm
     
    E. Robert Tisdale, Dec 13, 2004
    #2
    1. Advertising

  3. * :
    > Could some C++ guru please help me? I am using a BigInteger class which
    > is really
    > a wrapper around a C source file(mpi.c) that does arbitrary precision
    > arithmetic operations. When I compile the C file using gcc -g -o mpi
    > mpi.c rng.c -lm
    > there are NO compilation or linking errors. However, when I try to
    > compile the
    > C++ wrapper class using g++ -g -o bigint bigint.C mpi.c rng.c -lm, I
    > get strange linkage problems that all the functions in the C
    > file(mpi.c) are 're-defined'. I have checked over and over, but there
    > is no re-definition of the functions. I have not posted the source
    > code, as it is fairly huge. Could someone provide some
    > ideas as to what might be going wrong? I am using gcc 3.2.3. Thanks in
    > advance for your help!


    You have probably #include'd [mpi.c], the function definitions, in
    [bigint.C] or in a file #include'd by [bigint.C], instead of
    #include'ing [mpi.h], just the function declarations.

    In that case there are two resolution: (1) leave out [mpi.c] in the g++
    command line (i.e. this is how you want it), or (2) change the #include.

    Method (2) is the recommended one, because #include of definitions is
    often very problematic.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Dec 13, 2004
    #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. Thinkit
    Replies:
    8
    Views:
    528
    Thinkit
    Dec 24, 2003
  2. Honestmath
    Replies:
    5
    Views:
    563
    Honestmath
    Dec 13, 2004
  3. Alasdair
    Replies:
    15
    Views:
    765
    Steven D'Aprano
    Mar 9, 2008
  4. Martin the Third
    Replies:
    8
    Views:
    380
    Kai-Uwe Bux
    Jun 13, 2008
  5. Replies:
    1
    Views:
    593
    Michael DOUBEZ
    Sep 12, 2008
Loading...

Share This Page