An error which is driving me slowly mad

G

Grey Knight

Here's a problem which is driving me slowly insane. Using GCC version
3.3.1 on SuSE 9.0, I keep getting "undefined reference to
`function'"-type errors for no apparent reason! It's driving me
bonkers. Here's a tiny sample program which reproduces the problem.
I've also included an extract of the shell session I used to launch it
(so you can tell me if I'm missing any crucial commandline
parameters), and an excerpt from the -aux-info dump which seems to say
that the function in question WAS in fact defined.

It's enough to make me gibber!


/**SOF:"test.c"**/
#include <stdio.h>
#include <math.h>

int main(int argc, char* argv[]) {
double x;
for(x=0; x<=32; x++) {
printf("%2.0f : %6.3f\n",x,sin(x*3.141592653/16));
}
}
/**EOF**/


/**SOT:"shell extract"**/
greyknight@gaius:> gcc -aux-info test.dump -o test test.c

/tmp/ccO1su8V.o(.text+0x55): In function `main':
: undefined reference to `sin'
collect2: ld returned 1 exit status
bash: ./test: No such file or directory
/**EOT**/


/**SOT:"test.dump extract"**/
/* /usr/include/bits/mathcalls.h:66:NC */ extern double sin (double);
/**EOT**/
 
J

Joona I Palaste

Grey Knight said:
Here's a problem which is driving me slowly insane. Using GCC version
3.3.1 on SuSE 9.0, I keep getting "undefined reference to
`function'"-type errors for no apparent reason! It's driving me
bonkers. Here's a tiny sample program which reproduces the problem.
I've also included an extract of the shell session I used to launch it
(so you can tell me if I'm missing any crucial commandline
parameters), and an excerpt from the -aux-info dump which seems to say
that the function in question WAS in fact defined.

You'll want to add -lm to your GCC invocation command line.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top