Need help compiling jpegtran.c code from libjpeg

See below for updates.

I ran into a number of odd problems. First, I use the latest Eclipse CDT and before implementing do_rot_180 , the compiler linked the projectName / include folder, but after it now requires a specific include / *. H indicated below.

Due to this problem, in the project explorer, it seems that libjpeg.h is missing or invalid, despite the fact that it is in a folder on the disk.

I am working with libjpeg-9.

eclipse issue

Includes (includes the contents of transupp.c and example.c):

includes in eclipsehard drive includes

Functions (do_rot_180 - from transupp.c, and read_JPEG_file - from example.c):

See updated code block below under Edit 2 (pretty much just jpegtran.c code) This is the rotate function which is unused in jpegtran.c: //LOCAL(void) //do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, // JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, // jvirt_barray_ptr *src_coef_arrays, // jvirt_barray_ptr *dst_coef_arrays) ///* 180 degree rotation is equivalent to // * 1. Vertical mirroring; // * 2. Horizontal mirroring. // * These two steps are merged into a single processing routine. // */ //{ // JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; // JDIMENSION x_crop_blocks, y_crop_blocks; // int ci, i, j, offset_y; // JBLOCKARRAY src_buffer, dst_buffer; // JBLOCKROW src_row_ptr, dst_row_ptr; // JCOEFPTR src_ptr, dst_ptr; // jpeg_component_info *compptr; // // MCU_cols = srcinfo->output_width / // (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); // MCU_rows = srcinfo->output_height / // (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); // // for (ci = 0; ci < dstinfo->num_components; ci++) { // compptr = dstinfo->comp_info + ci; // comp_width = MCU_cols * compptr->h_samp_factor; // comp_height = MCU_rows * compptr->v_samp_factor; // x_crop_blocks = x_crop_offset * compptr->h_samp_factor; // y_crop_blocks = y_crop_offset * compptr->v_samp_factor; // for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; // dst_blk_y += compptr->v_samp_factor) { // dst_buffer = (*srcinfo->mem->access_virt_barray) // ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, // (JDIMENSION) compptr->v_samp_factor, TRUE); // if (y_crop_blocks + dst_blk_y < comp_height) { // /* Row is within the vertically mirrorable area. */ // src_buffer = (*srcinfo->mem->access_virt_barray) // ((j_common_ptr) srcinfo, src_coef_arrays[ci], // comp_height - y_crop_blocks - dst_blk_y - // (JDIMENSION) compptr->v_samp_factor, // (JDIMENSION) compptr->v_samp_factor, FALSE); // } else { // /* Bottom-edge rows are only mirrored horizontally. */ // src_buffer = (*srcinfo->mem->access_virt_barray) // ((j_common_ptr) srcinfo, src_coef_arrays[ci], // dst_blk_y + y_crop_blocks, // (JDIMENSION) compptr->v_samp_factor, FALSE); // } // for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { // dst_row_ptr = dst_buffer[offset_y]; // if (y_crop_blocks + dst_blk_y < comp_height) { // /* Row is within the mirrorable area. */ // src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; // for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { // dst_ptr = dst_row_ptr[dst_blk_x]; // if (x_crop_blocks + dst_blk_x < comp_width) { // /* Process the blocks that can be mirrored both ways. */ // src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; // for (i = 0; i < DCTSIZE; i += 2) { // /* For even row, negate every odd column. */ // for (j = 0; j < DCTSIZE; j += 2) { // *dst_ptr++ = *src_ptr++; // *dst_ptr++ = - *src_ptr++; // } // /* For odd row, negate every even column. */ // for (j = 0; j < DCTSIZE; j += 2) { // *dst_ptr++ = - *src_ptr++; // *dst_ptr++ = *src_ptr++; // } // } // } else { // /* Any remaining right-edge blocks are only mirrored vertically. */ // src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x]; // for (i = 0; i < DCTSIZE; i += 2) { // for (j = 0; j < DCTSIZE; j++) // *dst_ptr++ = *src_ptr++; // for (j = 0; j < DCTSIZE; j++) // *dst_ptr++ = - *src_ptr++; // } // } // } // } else { // /* Remaining rows are just mirrored horizontally. */ // src_row_ptr = src_buffer[offset_y]; // for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { // if (x_crop_blocks + dst_blk_x < comp_width) { // /* Process the blocks that can be mirrored. */ // dst_ptr = dst_row_ptr[dst_blk_x]; // src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; // for (i = 0; i < DCTSIZE2; i += 2) { // *dst_ptr++ = *src_ptr++; // *dst_ptr++ = - *src_ptr++; // } // } else { // /* Any remaining right-edge blocks are only copied. */ // jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, // dst_row_ptr + dst_blk_x, // (JDIMENSION) 1); // } // } // } // } // } // } //} 

Also, I cannot find where jcopy_block_row is . I looked through all the include files and their .c copies.

I commented on the error handling stuff in the read_JPEG_file function and want to call do_rot_180 from the inside, but I haven't received it yet.

The only key I found is in transupp.c:

transupp.c

Additional note: jpegtran.exe works separately with the compiled .DLL, so it should be somewhere.


Edit - copied jpegint.h over enable / resolved inclusion issues.

 #ifdef JPEG_INTERNALS #include "jpegint.h" /* fetch private declarations */ #include "jerror.h" /* fetch error codes too */ #endif 

Now it cannot compile, although they all seem to be declared in jpeglib.h or jpegint.h:

undefined referenced (4)


Edit 2 - the code now contains jpegtran.c material to rotate 180 degrees. Updated code block:

 /*********************************************************************************/ /* Defines */ /*********************************************************************************/ #define JPEG_INTERNALS /*********************************************************************************/ /* Includes */ /*********************************************************************************/ #include <stdio.h> #include <iostream> #include "jinclude.h" #include "jpeglib.h" #include "cdjpeg.h" #include "transupp.h" #include "jerror.h" #include <ctype.h> #include <setjmp.h> //using namespace std; static char * infilename; static char * outfilename; static JCOPY_OPTION copyoption; static jpeg_transform_info transformoption; FILE * infile; FILE * outfile; void openFile(char file) { if(file == 'i') { infile = fopen(infilename, "rb"); } else if(file == 'o') { outfile = fopen(outfilename, "wb"); } } /*********************************************************************************/ /* Main Execution Block */ /*********************************************************************************/ int main() { struct jpeg_decompress_struct srcinfo; struct jpeg_compress_struct dstinfo; struct jpeg_error_mgr jsrcerr, jdsterr; jvirt_barray_ptr * src_coef_arrays; jvirt_barray_ptr * dst_coef_arrays; //int file_index; srcinfo.err = jpeg_std_error(&jsrcerr); jpeg_create_decompress(&srcinfo); dstinfo.err = jpeg_std_error(&jdsterr); jpeg_create_compress(&dstinfo); jsrcerr.trace_level = jdsterr.trace_level; srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; // outfilename = NULL; copyoption = JCOPYOPT_DEFAULT; transformoption.transform = JXFORM_NONE; transformoption.trim = FALSE; transformoption.force_grayscale = FALSE; transformoption.transform = JXFORM_ROT_180; // std::cout << "Enter a filename to rotate 180 degrees." << std::endl; std::cin >> infilename; openFile('i'); std::cout << "Enter the output filename." << std::endl; std::cin >> outfilename; openFile('o'); // jpeg_stdio_src(&srcinfo, infile); jcopy_markers_setup(&srcinfo, copyoption); (void) jpeg_read_header(&srcinfo, TRUE); jtransform_request_workspace(&srcinfo, &transformoption); src_coef_arrays = jpeg_read_coefficients(&srcinfo); jpeg_copy_critical_parameters(&srcinfo, &dstinfo); dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, src_coef_arrays, &transformoption); jpeg_stdio_dest(&dstinfo, outfile); jpeg_write_coefficients(&dstinfo, dst_coef_arrays); jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); jtransform_execute_transformation(&srcinfo, &dstinfo, src_coef_arrays, &transformoption); jpeg_finish_compress(&dstinfo); jpeg_destroy_compress(&dstinfo); (void) jpeg_finish_decompress(&srcinfo); jpeg_destroy_decompress(&srcinfo); // if (infile != stdin) fclose(infile); if (outfile != stdout) fclose(outfile); return 0; } /*********************************************************************************/ /* End of Program */ /*********************************************************************************/ 

Edit 3 - Made the changes that Jeff mentioned, and I encounter this problem when compiling (in Eclipse):

 cannot find -lC:\Users\tmp\workspace2\jpegManipulator\lib\libjpeg.a jpegManipulator C/C++ Problem Invalid project path: Duplicate path entries found (/jpegManipulator [Include path] base-path:jpegManipulator isSystemInclude:true includePath:include), path: [/jpegManipulator].jpegManipulator pathentry Path Entry Problem 

I have a workspace / lib directory specified as the library source, as well as a specific libjpeg.a library installed on the libraries tab. It is definitely in the directory.

If I do not specify a specific libjpeg.a file, it complains about the lack of function references, but if I turn it on, it complains that libjpeg.a was not found. This is for v9 and v6b.

 cannot find -lC:\Users\tmp\workspace2\jpeg6bmanip\libs\libjpeg.a jpeg6bmanip C/C++ Problem cannot find -lC:\Users\tmp\workspace2\jpeg6bmanip\libs\libjpeg.la jpeg6bmanip C/C++ Problem 

Solution to the problem Change 3 : https://stackoverflow.com/q/14692302/1666510 , but a new problem after that. The program cannot be started or debugged because it claims to be unable to find jpeglib.h .

0
source share
1 answer

I had something similar arising when developing with MinGW a couple of years ago. I had to download the source for libjpeg and create it on my machine to get the libjpeg.a file. The source can be found here:

http://www.ijg.org/

The problem that I discovered when creating this library was that when I ran "nm libjpeg.a", it became clear that the characters in cdjpeg.h and transupp.h were not compiled into the library. I could not find a way to do this through configure, since I did not see anything obvious when I configured -help. Instead, I edited the Makefile.in file, where it defines a list of .lo files. Am__objects_1. I added cdjpeg and transupp at the end as follows:

 am__objects_1 = jaricom.lo jcapimin.lo jcapistd.lo jcarith.lo \ jccoefct.lo jccolor.lo jcdctmgr.lo jchuff.lo jcinit.lo \ jcmainct.lo jcmarker.lo jcmaster.lo jcomapi.lo jcparam.lo \ jcprepct.lo jcsample.lo jctrans.lo jdapimin.lo jdapistd.lo \ jdarith.lo jdatadst.lo jdatasrc.lo jdcoefct.lo jdcolor.lo \ jddctmgr.lo jdhuff.lo jdinput.lo jdmainct.lo jdmarker.lo \ jdmaster.lo jdmerge.lo jdpostct.lo jdsample.lo jdtrans.lo \ jerror.lo jfdctflt.lo jfdctfst.lo jfdctint.lo jidctflt.lo \ jidctfst.lo jidctint.lo jquant1.lo jquant2.lo jutils.lo \ jmemmgr.lo cdjpeg.lo transupp.lo @ MEMORYMGR@.lo 

Then I did "make" and "make install", and the characters were in the library. At this point, I was able to get the code to build. An auto-tuning expert may come up with a better way to do this, but it will at least get you to work.

+1
source

All Articles