Question

Well, I think my problem is a little bit interesting and I want to understand what's happening in my Ubuntu box.

I compiled and linked with gcc -lm -o useless useless.c the following useless piece of code:

/*File useless.c*/
#include <stdio.h>
#include <math.h>
int main()
{
    int sample = (int)(0.75 * 32768.0 * sin(2 * 3.14 * 440 * ((float) 1/44100)));
    return(0);
}

So far so good. But when I change to this:

/*File useless.c*/
#include <stdio.h>
#include <math.h>
int main()
{
    int freq = 440;
    int sample = (int)(0.75 * 32768.0 * sin(2 * 3.14 * freq * ((float) 1/44100)));
    return(0);
}

And I try to compile using same command line, gcc responses:

/tmp/cctM0k56.o: In function `main':
ao_example3.c:(.text+0x29): undefined reference to `sin'
collect2: ld returned 1 exit status

And stops. What is happening? Why I can't compile that way?

I tried also a sudo ldconfig -v without success.

Thanks in Advance!

Lucas.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top