undefined reference to `trunc'

G

Giulio

I can't understand where is the problem:
this is the file I would like to compile
------------------------
#include <math.h>
#include <stdlib.h>

int main (){
int c = trunc(17.5);
return c;
}
 
?

=?ISO-8859-1?Q?Bj=F8rn_Augestad?=

Giulio said:
I can't understand where is the problem:
this is the file I would like to compile
------------------------
#include <math.h>
#include <stdlib.h>

int main (){
int c = trunc(17.5);
return c;
}

Try gcc -o prova prova.c -lm
where m is for the math library and the l is the letter ell.

HTH
Bjørn
 
J

jacob navia

Bjørn Augestad said:
Try gcc -o prova prova.c -lm
where m is for the math library and the l is the letter ell.

HTH
Bjørn

Ahhh couldn't gcc include the math lib by default?????

The few microseconds that this would cost in modern machines
would be *really* justified by the easier user interface.

This is a relic of the old days when machines were so slow that
including or not the math lib made a difference in link time.

Today, this is completely obsolete.

jacob
 
J

Jack Klein

Ahhh couldn't gcc include the math lib by default?????

The few microseconds that this would cost in modern machines
would be *really* justified by the easier user interface.

This is a relic of the old days when machines were so slow that
including or not the math lib made a difference in link time.

Today, this is completely obsolete.

jacob

Yes, of course, but this comes from the *NIX world, where the gurus
will NEVER give up their advantage over newbies. They want the
newcomers to come groveling to their betters.
 
J

Jens.Toerring

Yes, of course, but this comes from the *NIX world, where the gurus
will NEVER give up their advantage over newbies. They want the
newcomers to come groveling to their betters.

Aren't you a bit harsh here? I guess it got more to do with the fact
that there are that many different implementations of UNIX that it
takes a lot longer for such changes to get adopted by everyone. That's
quite a bit more difficult than in a world where you have a single
company that can tell everyone how to do things and rewrite every-
thing you have because they decided to do things differently without
having to get a consensus.
Regards, Jens
 
D

Dave Vandervies

Aren't you a bit harsh here? I guess it got more to do with the fact
that there are that many different implementations of UNIX that it
takes a lot longer for such changes to get adopted by everyone. That's
quite a bit more difficult than in a world where you have a single
company that can tell everyone how to do things and rewrite every-
thing you have because they decided to do things differently without
having to get a consensus.

Jack may be being too harsh, but you're being too generous, so it
balances out.

Unix culture has a "It works this way, it's worked this way for a long
time, why waste energy changing it?" attitude that assumes easy access
to the corresponding oral tradition and causes problems without that.

"You know that now, so we still don't need to change it" tends to work a
lot better when everybody can go visit the guru down the hall than when
people are trying to learn it on their own.


dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top