Question

I have a PS3 that I've installed YDL 6.1 and SDK 3.1 on and everything seems to be working fine, as I can compile and run the examples. However, I've run into some problems with writing programs of my own. I've created a small test case that seems to pinpoint the cause of the failure. I have the following code:

// mathtest.c
#include <stdio.h>
#include <math.h>

int main ()
{
  double param, result;
  param = 1024.0;
  result = sqrt (param);
  printf ("sqrt(%lf) = %lf\n", param, result );
  return 0;
}

When I then run

ppu-gcc mathtest.c

I get the following error

/tmp/ccFqwJdG.o:(.text+0x20): undefined reference to `sqrt'
collect2: ld returned 1 exit status

I already checked to make sure that math.h exists on this system and it does define sqrt. I also already tried running this:

ppu-gcc -I/usr/includes/ mathtest.c

but it results in the same error. I'm confused, anyone have any ideas?

Was it helpful?

Solution

I sometimes got similar errors on Linux, using -lm as a gcc parameter helped there. Perhaps it does here, too. The parameter tells the linker to include the math library, too.

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