Page 1 of 1

Sin Math Function Error Compiling

Posted: Wed Aug 03, 2022 10:29 am
by ggalanprytimemedical
I have the following error when trying to compile

gcc main.c -o a.out -lphidget22

/usr/bin/ld: /tmp/ccoh9Nkx.o: undefined reference to symbol 'sin@@GLIBC_2.4'
/usr/bin/ld: /lib/arm-linux-gnueabihf/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

The code is

#include <math.h>
double sinx = sin(0);

What I am missing.

Re: Sin Math Function Error Compiling

Posted: Wed Aug 03, 2022 11:54 am
by Patrick
you probably need to add -lm to your gcc line to include the math library.

-Patrick

Re: Sin Math Function Error Compiling

Posted: Thu Aug 04, 2022 8:53 am
by ggalanprytimemedical
Thanks, that works.