Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > PLEASE HELP - Linkage problem in gcc 3.2.3 with arbitrary precision arithmetic

Reply
Thread Tools

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

 
 
cpptutor2000@yahoo.com
Guest
Posts: n/a
 
      12-13-2004
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!

 
Reply With Quote
 
 
 
 
E. Robert Tisdale
Guest
Posts: n/a
 
      12-13-2004
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
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      12-13-2004
* :
> 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?
 
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
c++ linkage vs c linkage ramasubramanian.rahul@gmail.com C++ 1 09-12-2008 11:41 AM
Heap overflow/corruption problem in an arbitrary precision class Martin the Third C++ 8 06-13-2008 07:47 PM
Arbitrary precision integer arithmetic: ceiling? Alasdair Python 15 03-09-2008 12:09 PM
calling an arbitrary function w/ arbitrary arguments Honestmath C++ 5 12-13-2004 06:18 AM
Arbitrary precision binary float class Thinkit Java 8 12-24-2003 12:26 AM



Advertisments