473,394 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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!

Jul 22 '05 #1
2 1457
cp**********@yahoo.com 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
Jul 22 '05 #2
* cp**********@yahoo.com:
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?
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thinkit | last post by:
Are there any packages for arbitrary precision binary floats? Something along the lines of Gnu Multi Precision. I saw quite a few rationals classes, but not this. Just looking to be able to use...
5
by: Mattias Brändström | last post by:
Hello! I am trying to find a minimal class/lib that handles arbitrary precision decimal numbers. I would be happy if this class supported as little as addition, subtraction, multiplication,...
5
by: buddyletts | last post by:
Below is some test code: #include <iostream> #include <cmath> using namespace std; int main() { double P = -1943.6650940829325; double R = 3.6683591763449312;
37
by: Protoman | last post by:
Hi!!! Protoman here, I need to write an infinite precision number class b/c I want to compute pi. Give me some sample code. Also, when I run my program and it computes pi, will my computer freeze...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
12
by: Chadwick Boggs | last post by:
I need to perform modulo operations on extremely large numbers. The % operator is giving me number out of range errors and the mod(x, y) function simply seems to return the wrong results. Also,...
15
by: Donkey | last post by:
Hi, The precision of built-in date type of C is very low. Even using long double float type or double float type, we can only use 12 or 16 digits after the decimal point. What can we do if we want...
15
by: Alasdair | last post by:
I need to apply the ceiling function to arbitrary sized (long) integers. However, division automatically returns the type of its operands, so that, for example: math.ceil(7/4) returns 1. I can use...
2
by: Rob Clewley | last post by:
Dear Pythonistas, How many times have we seen posts recently along the lines of "why is it that 0.1 appears as 0.10000000000000001 in python?" that lead to posters being sent to the definition...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.