Sin Math Function Error Compiling

C, C++, and Visual C++
Post Reply
ggalanprytimemedical
Phidgetsian
Posts: 5
Joined: Fri Jul 15, 2022 5:44 pm
Contact:

Sin Math Function Error Compiling

Post 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.
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Sin Math Function Error Compiling

Post by Patrick »

you probably need to add -lm to your gcc line to include the math library.

-Patrick
ggalanprytimemedical
Phidgetsian
Posts: 5
Joined: Fri Jul 15, 2022 5:44 pm
Contact:

Re: Sin Math Function Error Compiling

Post by ggalanprytimemedical »

Thanks, that works.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests