while I am trying to install a software, following the instructions, I did some thing wrong, and now I can not compile some C sources. for example, a very small code including a call to math.h, and a call to function sin() gives an error.
I downloaded the latest version of GCC, but installing it with yast did not solve the problem.
Any suggestions?
Erkut
Build output from Mono Development Environment 2.2 is here
Building: dft (Release)
Building Solution dft
Building: dft (Release)
Performing main compilation…
Precompiling headers
Compiling source to object files
Generating binary “dft” from object files
gcc -o “/home/erkut/projects/dft/dft/dft/bin/Release/dft” “/home/erkut/projects/dft/dft/dft/bin/Release/main.o”
/home/erkut/projects/dft/dft/dft/bin/Release/main.o: In function DFT': main.c:(.text+0xb8): undefined reference to
sin’
collect2: ld returned 1 exit status
Build complete – 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings
And the source code is here
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
// Direct fourier transform
int DFT(int dir,int m,double *x1,double *y1)
{
long i,k;
double arg_;
double cosarg,sinarg;
double *x2=NULL,*y2=NULL;
x2 = malloc(msizeof(double));
y2 = malloc(msizeof(double));
if (x2 == NULL || y2 == NULL)
return(0);
for (i=0;i<m;i++) {
x2* = 0;
y2* = 0;
arg_ = - dir * 2.0 * 3.141592654 * (double)i / (double)m;
for (k=0;k<m;k++) {
cosarg = cos(k * arg_); /***** compile error at this line, and the following one ***********/
sinarg = sin(arg_ * k);
x2 += (x1[k] * cosarg - y1[k] * sinarg);
y2 += (x1[k] * sinarg + y1[k] * cosarg);
}
}
// Copy the data back
if (dir == 1) {
for (i=0;i<m;i++) {
x1* = x2* / (double)m;
y1* = y2* / (double)m;
}
} else {
for (i=0;i<m;i++) {
x1* = x2*;
y1* = y2*;
}
}
free(x2);
free(y2);
return(1);
}
int main (int argc, char *argv])
{
FILE *f;
char *b[80];
double x1[360],y1[360];
int i,l;
for (i=0;i<360;i++)
y1*=0;
f=fopen("//home/erkut/projects/dft/data", "r");
if(!f){
printf ("No Files!
");
}
i=0;
while(!feof(f)) {
fscanf(f,"%s", b);
x1* = atof((char *)b);
}
printf("?i = %d
",i);
for (l=0;l<i;l++)
printf("%d : %f
", l, x1[l]);
//DFT(1, 360, x1, y1);
return 0;
}**************