472,968 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,968 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 7477
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.