Mail Archives: cygwin/2001/04/05/12:32:14
Hi
I hope that it is the right place to ask my question.
I am trying to compile a C program under Cygwin with gcc but I got errors.
My configuration is :
Laptop Compaq serie 1200 Model 12XL222
56Mo RAM (64-8 for Video)
HD 6Go split in 2 partitions 4Go and 2Go
OS : Windows 98 SE
My file is in the 2Go partition and Cygwin as well
Can somebody tell me what's wrong.
Regards
Jean-Luc
Here is the error
latyr AT LATYR /cygdrive/d/allprogs
$ gcc -lm -otest.exe image1.c
/cygdrive/c/WINDOWS/TEMP/ccobIwme.o(.text+0x4bc):image1.c: multiple
definition of `main'
/usr/lib/libm.a(libcmain.o)(.text+0x0):libcmain.c: first defined here
/usr/lib/libm.a(libcmain.o)(.text+0x6a):libcmain.c: undefined reference to
`WinMain AT 16'
collect2: ld returned 1 exit status
latyr AT LATYR /cygdrive/d/allprogs
$
Here is my code
#include <stdio.h>
#include <math.h>
#define N 8
#define M 8
#define pi 3.141592654
#define coeff 0.707106781
static double block1[M][N]={
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255}};
static double block2[M][N]={
{ 0, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255},
{255, 255, 255, 255, 255, 255, 255, 255}};
static double block3[M][N]={
{255, 255, 255, 255, 255, 255, 255, 255},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{255, 255, 255, 255, 255, 255, 255, 255},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{255, 255, 255, 255, 255, 255, 255, 255},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{255, 255, 255, 255, 255, 255, 255, 255},
{ 0, 0, 0, 0, 0, 0, 0, 0}};
/********************************************************
* void dct(double forward[M][N], double DCT[M][N]) *
* Forward Discrete Cosine Transform of MxN array *
* Parameters : *
* forward - MxN array of data to transform *
* DCT - MxN array of transformed data *
********************************************************/
void dct(double forward[M][N], double DCT[M][N])
{
int u, v; /* Frequency domain variables */
int x, y; /* Spatial domain variables */
double accum; /* Accumulator */
double twoN; /* 2 times N */
double twoM; /* 2 times M */
double scale; /* 2/square_root(MN) */
twoN=2.0*N;
twoM=2.0*M;
scale=(2.0/(sqrt((double)(M*N))));
for(u=0; u<M; u++)
for(v=0; v<N; v++)
{
accum=0.0;
for(x=0; x<M; x++)
for(y=0; y<N; y++)
accum+=(cos((pi*u*(2*x+1))/twoM)*
cos((pi*v*(2*y+1))/twoN)*forward[x][y]);
accum*=scale;
if(u==0)
accum*=coeff;
if(v==0)
accum*=coeff;
DCT[u][v]=accum;
}
}
/********************************************************
* void inv_dct(double DCT[M][N], double inverse[M][N]) *
* Inverse Discrete Cosine Transform of MxN array *
* Parameters : *
* DCT - MxN array of data for inverse transform *
* inverse - MxN array of inversed transformed data*
********************************************************/
void inv_dct(double DCT[M][N], double inverse[M][N])
{
int u, v; /* Frequency domain variables */
int x, y; /* Spatial domain variables */
double accum; /* Accumulator */
double twoN; /* 2 times N */
double twoM; /* 2 times M */
double scale; /* 2/square_root(MN) */
double Cu, Cv; /* C(u) and C(v) */
twoN=2.0*N;
twoM=2.0*M;
scale=(2.0/(sqrt((double)(M*N))));
for(x=0; x<M; x++)
for(y=0; y<N; y++)
{
accum=0.0;
for(u=0; u<M; u++)
for(v=0; v<N; v++)
{
if(u==0)
Cu=coeff;
else
Cu=1.0;
if(v==0)
Cv=coeff;
else
Cv=1.0;
accum+=(Cu*Cv*cos((pi*u*(2*x+1))/twoM)*
cos((pi*v*(2*y+1))/twoN)*DCT[u][v]);
}
inverse[x][y]=accum*scale;
}
}
/***************************************************************************
* MAIN Function *
****************************************************************************
/
int main()
{
double dct_result[M][N], inv_dct_result[M][N];
int i, j;
/*** Set a 2-step loop to init the result matrix ***/
for(i=0;i<M;i++)
for(j=0;j<N;j++)
dct_result[i][j]=inv_dct_result[i][j]=0.0;
printf("\n\t******************************");
printf("\n\t***** Block 1 **********");
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",block1[i][j]);
}
printf("\n");
printf("\n\t***** FORWARD DCT **********");
dct(block1, dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",dct_result[i][j]);
}
printf("\n");
printf("\n\t***** INVERSE DCT **********");
inv_dct(dct_result, inv_dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",inv_dct_result[i][j]);
}
printf("\n");
printf("\n\t******************************");
/*** Set a 2-step loop to init the result matrix ***/
for(i=0;i<M;i++)
for(j=0;j<N;j++)
dct_result[i][j]=inv_dct_result[i][j]=0.0;
printf("\n\t******************************");
printf("\n\t***** Block 2 **********");
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",block2[i][j]);
}
printf("\n");
printf("\n\t***** FORWARD DCT **********");
dct(block2, dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",dct_result[i][j]);
}
printf("\n");
printf("\n\t***** INVERSE DCT **********");
inv_dct(dct_result, inv_dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",inv_dct_result[i][j]);
}
printf("\n");
printf("\n\t******************************");
/*** Set a 2-step loop to init the result matrix ***/
for(i=0;i<M;i++)
for(j=0;j<N;j++)
dct_result[i][j]=inv_dct_result[i][j]=0.0;
printf("\n\t******************************");
printf("\n\t***** Block 3 **********");
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",block3[i][j]);
}
printf("\n");
printf("\n\t***** FORWARD DCT **********");
dct(block3, dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",dct_result[i][j]);
}
printf("\n");
printf("\n\t***** INVERSE DCT **********");
inv_dct(dct_result, inv_dct_result);
for(i=0;i<M;i++)
{
printf("\n");
for(j=0;j<N;j++)
printf("\t%df",inv_dct_result[i][j]);
}
printf("\n");
printf("\n\t******************************");
return 0;
}
---
Latyr Jean-Luc FAYE
http://faye.cjb.net
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -