Fwd: help in the usage of compiling c files
Aileen Sengupta <[email protected]> Thu, 24 Sep 2020 11:44:45 -0500
| Newsgroups | gmane.comp.gnu.mingw.user |
|---|---|
| Message-ID | <CA+9v=0pLjr9ASxc_LR10sG3t1L025F=v=jvbrHA_MNjV_XJz+Q@mail.gmail.com> |
---------- Forwarded message --------- From: Aileen Sengupta <[email protected]> Date: Mon, 21 Sep 2020, 01:18 Subject: help in the usage of compiling c files To: <[email protected]> Dear Team, I have recently installed the MinGW and I am trying to run the following command gcc -o encoder jpegll_enc.c idc.h readimage.c image_size.c and I get the following error: [image: image.png] I have all the necessary files in the same folder as shown in the command prompt. I have attached the files in the email. I have tried every possible solutions and I needed help. Can you help me with the possible solution? -- Thanks and Regards, Aileen Sengupta https://sites.google.com/site/aileensengupta/ https://in.linkedin.com/in/aileen-sengupta-91547a24 _______________________________________________ MinGW-Users mailing list [email protected] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.osdn.me/mailman/listinfo/mingw-users Also: mailto:[email protected]?subject=unsubscribe
image.png
(image/png, 50.9 KB) - not displayed
jpegll_enc.c
(text/x-c-code, 8.3 KB)
#include <stdio.h>
#include <unistd.h>
#include "idc.h"
/**********************************************************************
* *
* File: jpegll_enc.c *
* Function: decorrelates an image using the lossless JPEG predictors *
* Author (aka person to blame) : K. Sayood *
* Last mod: 5/12/95 *
* Usage: see usage() *
***********************************************************************/
/*******************************************************************************
*NOTICE: *
*This code is believed by the author to be bug free. You are free to use and *
*modify this code with the understanding that any use, either direct or *
*derivative, must contain acknowledgement of its author and source. The author*
*makes no warranty of any kind, expressed or implied, of merchantability or *
*fitness for a particular purpose. The author shall not be held liable for any*
*incidental or consequential damages in connection with or arising out of the *
*furnishing, performance, or use of this software. This software is not *
*authorized for use in life support devices or systems. *
********************************************************************************/
void usage(void);
void main(int argc, char **argv)
{
int row, col, row_size, col_size, temp, mode,pred;
char inimage[50], resimage[50];
unsigned char **image_in, **res_image;
int c;
FILE *ifp, *ofp;
extern int optind;
extern char *optarg;
ofp = stdout;
strcpy(resimage,"standard out");
mode = -1;
row_size = -1;
col_size = -1;
while((c=getopt(argc,argv,"i:o:m:x:y:h"))!=EOF)
{
switch (c){
case 'i':
strcpy(inimage,optarg);
break;
case 'o':
strcpy(resimage,optarg);
ofp = fopen(optarg,"wb");
break;
case 'm':
sscanf(optarg,"%d", &mode);
break;
case 'x':
sscanf(optarg,"%d", &row_size);
break;
case 'y':
sscanf(optarg,"%d", &col_size);
break;
case 'h':
usage();
exit(1);
}
}
if(mode < 0)
{
fprintf(stderr,"Enter lossless JPEG mode (0 .. 7) :");
scanf("%d",&mode);
}
fprintf(stderr,"\n\n\t\tJPEG Lossless Compression \n");
fprintf(stderr,"This program generates the prediction error (residuals)\n");
fprintf(stderr,"using the different JPEG lossless predictive modes.\n");
fprintf(stderr,"The selected JPEG mode is %d and the residual image is written\n",mode);
fprintf(stderr,"to %s\n",resimage);
fprintf(stderr,"\n In order to obtain compression, these residuals should\n");
fprintf(stderr,"be encoded using a variable rate coder.\n");
/* If the image dimensions have not been provided find the image dimensions */
if(row_size < 0 || col_size < 0)
image_size(inimage, &row_size, &col_size);
fprintf(stderr,"\n Image size: %d X %d\n",col_size,row_size);
/* Assign space for the input and residual images */
image_in = (unsigned char **) calloc(row_size,sizeof(char *));
for(row=0; row<row_size; row++)
{
image_in[row] = (unsigned char *) calloc(col_size,sizeof(char));
}
res_image = (unsigned char **) calloc(row_size,sizeof(char *));
for(row=0; row<row_size; row++)
{
res_image[row] = (unsigned char *) calloc(col_size,sizeof(char));
}
/* Read the image to be decorrelated */
readimage(inimage, image_in, row_size, col_size);
/* Generate prediction using the prediction mode selected */
for(row=0; row<row_size; row++)
for(col=0; col<col_size; col++)
{
switch(mode) {
case 0:
pred = 0;
break;
case 1:
if(row == 0 && col == 0)
pred = 0;
else if(row==0)
pred = image_in[row][col -1];
else
pred = image_in[row-1][col];
break;
case 2:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else
pred = image_in[row][col -1];
break;
case 3:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else if(row==0)
pred = image_in[row][col -1];
else
pred = image_in[row-1][col - 1];
break;
case 4:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else if(row==0)
pred = image_in[row][col -1];
else
pred = image_in[row][col-1] + image_in[row-1][col] - image_in[row-1][col- 1];
break;
case 5:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else if(row==0)
pred = image_in[row][col -1];
else
pred = image_in[row][col-1] + (image_in[row-1][col] - image_in[row-1][col- 1])/2;
break;
case 6:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else if(row==0)
pred = image_in[row][col -1];
else
pred = image_in[row-1][col] + (image_in[row][col-1] - image_in[row-1][col- 1])/2;
break;
case 7:
if(row == 0 && col == 0)
pred = 0;
else if(col==0)
pred = image_in[row-1][col];
else if(row==0)
pred = image_in[row][col -1];
else
pred = (image_in[row][col-1] + image_in[row-1][col])/2;
break;
default:
fprintf(stderr,"No JPEG mode was specified");
exit(1);
}
/* Generate the residual */
temp = image_in[row][col] - pred;
/* Represent the residual modulo 256 */
if(temp < 0)
temp += 255;
if(temp > 255)
temp -= 255;
res_image[row][col] = temp;
}
/* Store JPEG mode and dimensions of the image */
fwrite(&mode,1,sizeof(int),ofp);
fwrite(&col_size,1,sizeof(int),ofp);
fwrite(&row_size,1,sizeof(int),ofp);
/* Store residual image */
for(row=0; row<row_size; row++)
for(col=0; col<col_size; col++)
putc(res_image[row][col],ofp);
}
void usage(void)
{
fprintf(stderr,"Usage: jpegll_enc [-i infile] [-o outfile] [-m mode]\n");
fprintf(stderr,"\t [-x row_size] [-y [col_size]\n");
fprintf(stderr,"\t infile : The file containing the image. It is assumed\n");
fprintf(stderr,"\t\t that the image is a grey level (8 bits/pixel) image\n");
fprintf(stderr,"\t\t stored in raw format. To read from standard in modify\n");
fprintf(stderr,"\t\t readimage.c\n");
fprintf(stderr,"\t outfile : The file containing the residual or decorrelated\n");
fprintf(stderr,"\t\t image. No variable lengrh coding has been performed so\n");
fprintf(stderr,"\t\t the outfile will be bigger than the infile. To get a\n");
fprintf(stderr,"\t\t compressed file use a variable length coder such as huff_enc\n");
fprintf(stderr,"\t\t on outfile. To pipe the output of this program directly\n");
fprintf(stderr,"\t\t to another program omit this option. This will result in\n");
fprintf(stderr,"\t\t the output being written to standard out.\n");
fprintf(stderr,"\t mode: an integer between 0 and 7 corresponding\n");
fprintf(stderr,"\t\t to the eight lossless JPEG modes\n");
fprintf(stderr,"\t row_size: Length of a row of the image\n");
fprintf(stderr,"\t col_size: Length of a column of the image\n");
fprintf(stderr,"\t\t If the column or row size is not provided the program\n");
fprintf(stderr,"\t\t will check to see if the iamge corresponds to any of the\n");
fprintf(stderr,"\t\t standard sizes it is familiar with. To add to the list of\n");
fprintf(stderr,"\t\t standard sizes, edit image_size.c\n\n");
}
readimage.c
(text/x-c-code, 2.3 KB)
#include <stdio.h>
void readimage(char filename[], unsigned char **image, int row_size, int col_size)
/***********************************************************************
* *
* File: readimage.c *
* Function: reads an image (what else :?) *
* Author : K. Sayood *
* Last mod: 5/12/95 *
* Usage: see usage() *
* *
* *
* filename[] : character string containing filename *
* **image : array of pointers pointing to the rows in an image *
* row_size : number of rows in the image *
* col_size : number of columns in the image. *
* *
***********************************************************************/
/*******************************************************************************
*NOTICE: *
*This code is believed by the author to be bug free. You are free to use and *
*modify this code with the understanding that any use, either direct or *
*derivative, must contain acknowledgement of its author and source. The author*
*makes no warranty of any kind, expressed or implied, of merchantability or *
*fitness for a particular purpose. The author shall not be held liable for any*
*incidental or consequential damages in connection with or arising out of the *
*furnishing, performance, or use of this software. This software is not *
*authorized for use in life support devices or systems. *
********************************************************************************/
{int r, c;
FILE *infile;
infile = fopen(filename,"rb");
if (infile == NULL)
{fprintf(stderr, "Unable to open file %s", filename);
exit(1);
}
for(r=0; r<row_size; r++)
fread(image[r],col_size,sizeof(char),infile);
fclose(infile);
}
idc.h
(text/x-c-code, 2.3 KB)
float ent(float [], int );
int image_size(char [], int *, int *);
void readimage(char [], unsigned char **, int, int);
int encuqi(int, int *, int);
int decuqi(int, int *);
void stuffit(int , int , FILE *, int );
int readnbits(int , FILE *);
int uquan_enc(float , float , int , float );
float uquan_dec(int, float, float );
int nuquan_enc(float , float [], int);
float nuquan_dec(int, float [] );
extern float rangen(int);
int vqencode( int *, int **, int, int,float *);
/* vqencode(input,codebook,codebook_size,dimension,&distortion)
returns the index in the codebook of the closest codeword */
void unstuff(int , FILE *, int *, int *);
int readau(char filename[], short aufile[]);
int get_file_size(char [], int *);
float predictor(int ,int ,float [],float [], float *);
void getim(char *fname, unsigned char *array, int size);
void storeim(char *fname, unsigned char *array, int size);
void sort(float *prob, int *loc,int num);
void huff(float prob[], int loc[], int num, unsigned int *code, char *length);
void diff(int *diffs, unsigned char *image, int rows, int cols,int num, unsigned char *dimage);
void getcode(FILE *fp, int num, unsigned int *code, char *length);
void value(int *values, unsigned char *image, int size,int num);
void images(int rows, int cols, int *code,char *length, unsigned char *file, unsigned char *dimage);
int files(int size,int *code,char *length,unsigned char *file);
/* define the structure node */
struct node {
float pro; /* probabilities */
int l; /* location of probability before sorted */
unsigned int code; /* code */
struct node *left; /* pointer for binary tree */
struct node *right; /* pointer for binary tree */
struct node *forward;
struct node *back;
struct node *parent; /* pointer to parent */
int check;
};
/* define subroutines and pointers to nodes */
typedef struct node NODE;
typedef struct NODE *BTREE;
BTREE create_list(float prob[], int loc[], int num);
void create_code(NODE *root, int lgth, unsigned int *code, char *length);
BTREE make_list (int num);
void write_code(NODE *root, int lgth, unsigned int *code, char *length, int *loc);
#define myabs(x) ((x)<0? -(x): (x))
image_size.c
(text/x-c-code, 3.2 KB)
#include <stdio.h>
#include <sys/stat.h>
#include <malloc.h> /* for halloc */
/*******************************************************************************
*NOTICE: *
*This code is believed by the author to be bug free. You are free to use and *
*modify this code with the understanding that any use, either direct or *
*derivative, must contain acknowledgement of its author and source. The author*
*makes no warranty of any kind, expressed or implied, of merchantability or *
*fitness for a particular purpose. The author shall not be held liable for any*
*incidental or consequential damages in connection with or arising out of the *
*furnishing, performance, or use of this software. This software is not *
*authorized for use in life support devices or systems. *
********************************************************************************/
int image_size(char file[], int *r, int *c)
{
/*
Written by James R. Nau, 6-Oct-89
Attempt to find the size of an image in file pointed to by *file.
Number of rows (down), and the number of columns (across) is returned.
Uses a stat call to find the size of the file. Then, attempts to find
a pertinent number of rows and columns that we normally use. Currently
supported formats:
row x column size Format
128x128 16,384 Small Image
320x200 64,000 IBM VGA Style
256x256 65,536 Standard NASA Image (small)
256x384 98,304 IVG Low-Res Image
512x384 196,608 IVG High-Res Image
512x512 262,144 Standard NASA Image (large)
640x480 307,200 Super VGA (from GIF usually)
720x480 345,600
576x720 414,720 JPEG images
Parameters:
*file: pointer to filename containing image
*row: pointer to the number of rows we decided on
*column: pointer to number of columns we decided on
Return values:
0: ok
-1: Couldn't use stat function
-2: Unknown image size
*/
struct stat status;
int res;
long img_len;
res = stat (file, &status);
if (res != 0)
{
return (-1);
}
img_len = status.st_size;
if (img_len == 16384L) /* For BUD's images */
{
*r = 128;
*c = 128;
}
else if (img_len == 64000L) /* IBM VGA Screen */
{
*r = 200;
*c = 320;
}
else if (img_len == 65536L) /* Standard */
{
*r = 256;
*c = 256;
}
else if (img_len == 98304L) /* Low-Res IVG images */
{
*r = 256;
*c = 384;
}
else if (img_len == 196608L) /* Hi-Res IVG images */
{
*r = 512;
*c = 384;
}
else if (img_len == 262144L) /* Standard, but large... */
{
*r = 512;
*c = 512;
}
else if (img_len == 307200L) /* SVGA Hi-Res from GIFs */
{
*r = 480;
*c = 640;
}
else if (img_len == 345600L) /* mpeg frame 720 x 480 */
{
*r = 720;
*c = 480;
}
else if (img_len == 414720L) /* jpeg test image 576 x 720 */
{
*r = 576;
*c = 720;
}
else /* oops */
{
fprintf(stderr, "\nError, unknown image size: %ld\n", img_len);
return (-2);
}
return (0);
}