473,386 Members | 1,736 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,386 software developers and data experts.

g++ 3.2.X: undefined reference to `abs(int)'

hi,

I am sure that is a stupid error of mine, but why the hell
does this not work:
-------------------------------------------
g++ test.cc /tmp/ccUN1Hel.o: In function `main':
/tmp/ccUN1Hel.o(.text+0x26): undefined reference to `abs(int)'
collect2: ld returned 1 exit status
------------------------------------------- cat test.cc #include <stdlib.h>
#include <stdio.h>

int main(){
int abs(int);
for (int jj=10;jj>=-10;jj--){
fprintf(stdout,"%d ===> %d\n",jj,abs(jj));
}
return 0;
}
-------------------------------------------man 3 abs

ABS(3) Linux Programmer's
Manual ABS(3)
NAME
abs, labs, llabs, imaxabs - compute the absolute value of an
integer.
SYNOPSIS
#include <stdlib.h>

int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
-------------------------------------------
thanks, daniel
Jul 19 '05 #1
2 7560
Daniel Heiserer wrote:
hi,

I am sure that is a stupid error of mine, but why the hell
does this not work:
-------------------------------------------
g++ test.cc

/tmp/ccUN1Hel.o: In function `main':
/tmp/ccUN1Hel.o(.text+0x26): undefined reference to `abs(int)'
collect2: ld returned 1 exit status
-------------------------------------------
cat test.cc

#include <stdlib.h>
#include <stdio.h>

int main(){
int abs(int);


You don't need the above line. <stdlib.h> declares abs so you must not do
it.

--
Attila aka WW
Jul 19 '05 #2
Daniel Heiserer <Da*************@bmw.de> writes:

Hello,
#include <stdlib.h>
#include <stdio.h>
Should nowadays be:

#include <cstdlib>
#include <cstdio>

using namespace std;
int main(){
int abs(int);
Remove this line, that will solve the error.
for (int jj=10;jj>=-10;jj--){
fprintf(stdout,"%d ===> %d\n",jj,abs(jj));
}
return 0;
}


Bye,
Chris Dams
Jul 19 '05 #3

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

Similar topics

6
by: sandwich_eater | last post by:
using g++ in cygwin... sv.cpp:13: warning: passing `double' for converting 1 of `int abs(int)' extract... #include <stdlib.h> #include <Math.h> double pythag(double a, double b)
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
33
by: Evangelista Sami | last post by:
hello how can i know the size of an int in bits? i looked in limits.h but i did not find anything to get this thanks for any help
14
by: yang__lee | last post by:
Hi, You all know typedef typedef struct g { int a; int b; } google;
3
by: Michael | last post by:
Hi, I am a little confused about & and int &. Do they both mean reference? int a; int* b= & a ; (& here mean reference of a) int& b = a ; ( How to understand & precisely here?) Thanks...
13
by: John Doe | last post by:
If I include <cmathand write std::abs in my program I get: gcc -MD -o /home/bla/c++/.build/generator.o -c generator.cpp generator.cpp: In function 'int main(int, char**)': generator.cpp:206:...
15
by: arnuld | last post by:
-------- PROGRAMME ----------- /* Stroustrup, 5.6 Structures STATEMENT: this programmes *tries* to do do this in 3 parts: 1.) it creates a "struct", named "jd", of type "address". 2. it...
10
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the...
41
by: Summercool | last post by:
Can we confirm the following? also someone said, Java also has "reference" like in C++, which is an "implicit pointer": Pointer and Reference --------------------- I am starting to see what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.