1
I’m starting now in this life of programmer and I’m trying to perform a program for physics class but at the time of compiling the file is turning me this message... reach. c:(.text+0x68): undefined reference to cos'
alcance.c:(.text+0x93): referência indefinida para
sin'
collect2: error: Ld returned 1 Exit status
I’m using Emacs... gcc -lm -o range. c, I must send other information??
This is the part referring to consseno and sine
Rx=0.0;
Ry=0.0;
vx=v0*cos(theta*3141592/180.0);
Vy=v0*sin(theta*3.141592/180.0);
I must do the double cos, and double sin?
#include <stdio.h>
#include <math.h>
main ()
{
double ry;
double rx;
double vx;
double vy;
double ax;
double ay;
double dt;
double t;
double g;
double v0;
double theta;
double b; // [1/ms]coeficiente de arrasto
double dtheta; // angulo de lancamento
g=-10;
dt=0.1;//
v0=100;// velocidade inicial
dtheta=1;// angulo de lançamente
b=1;// coeficiente de arrato
for (theta=0;theta<=90;theta=theta=dtheta){
rx=0.0;
ry=0.0;
vx=v0*cos(theta*3141592/180.0);
vy=v0*sin(theta*3.141592/180.0);
for(t=0;t<=500;t=t+dt){
if(ry<0.0)break;
ax=0.0-b*vx;
ay=-g-b*vy;
rx=rx+vx*dt;
ry=ry+vy*dt;
vx=vx=ax*dt;
vy=vy+ay*dt;
}
#include <math.h>
printf("%f %f %f %f %f %f\n",theta,t,rx,ry,vx,vy);
}
return 0;
}
You tried to compile by putting
-lm
at the end as suggested by @pmg ?– Avelino