Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 需要从libjpeg编译JPEG.c代码的帮助吗_C++_Eclipse_Include_Eclipse Cdt_Libjpeg - Fatal编程技术网

C++ 需要从libjpeg编译JPEG.c代码的帮助吗

C++ 需要从libjpeg编译JPEG.c代码的帮助吗,c++,eclipse,include,eclipse-cdt,libjpeg,C++,Eclipse,Include,Eclipse Cdt,Libjpeg,有关更新,请参见底部 我遇到了一些奇怪的问题。首先,我使用的是最新的Eclipse CDT,在实现do_rot_180之前,编译器链接了文件夹projectName/include,但之后它现在需要下面指定的特定include/*.h 与此相关,在project explorer中,似乎认为libjpeg.h丢失或无效,尽管它位于磁盘上的文件夹中 我正在使用libjpeg-9 包括(包括transupp.c和example.c所包括的内容): 函数(do_rot_180来自transupp.

有关更新,请参见底部

我遇到了一些奇怪的问题。首先,我使用的是最新的Eclipse CDT,在实现do_rot_180之前,编译器链接了文件夹projectName/include,但之后它现在需要下面指定的特定include/*.h

与此相关,在project explorer中,似乎认为libjpeg.h丢失或无效,尽管它位于磁盘上的文件夹中

我正在使用libjpeg-9

包括(包括transupp.c和example.c所包括的内容):

函数(do_rot_180来自transupp.c,read_JPEG_文件来自example.c):

现在它无法编译,即使它们似乎都是在jpeglib.h或jpegint.h中声明的:


编辑2-代码现在包含jpegtran.c的东西,只能够旋转180度。更新的代码块:

/*********************************************************************************/
/* 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                                                                */
/*********************************************************************************/
我将工作区目录/lib设置为库源,并且在“库”选项卡中设置了特定的libjpeg.a库-它肯定在目录中

如果我没有包含特定的libjpeg.a文件,它会抱怨缺少函数引用,但如果我包含了它,它会抱怨说找不到libjpeg.a。这适用于v9和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

编辑3问题的解决方案:但之后会出现新问题。无法运行或调试该程序,因为它声称找不到jpeglib.h

几年前使用MinGW开发时,我遇到了类似的情况。为了得到libjpeg.a文件,我必须下载libjpeg的源代码并在我的机器上构建它。可在此处找到来源:

我在构建这个库时发现的问题是,当我执行'nm libjpeg.a'时,很明显cdjpeg.h和transupp.h中的符号没有被编译到库中。我找不到通过configure实现的方法,因为在执行“configure--help”时,我没有看到任何明显的内容。相反,我编辑了Makefile.in文件,它定义了.lo文件的am\u\u objects\u 1列表。我在末尾添加了cdjpeg和transupp,如下所示:

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

然后我做了一个“make”和一个“make-install”,这些符号出现在库中。在这一点上,我能够让您的代码生成。autotools专家可能会想出一个更好的方法,但这至少会让你成功。

谢谢你的建议,我会尝试一下。这听起来确实像是正在发生的事情。。在版本6b中,似乎没有在makefile中声明任何am_对象。还有什么我能做的吗?(正在v9中尝试)我认为您不想将其添加到Makefile中。将其放入Makefile.in应自动将.o引用放入Makefile中的正确位置。将消息添加到just Makefile.in时是否会收到相同的消息?这听起来像是Makefile.in中的一个输入错误。我下载了jpegsr6b.zip并查看了Makefile。看起来您需要将cdjpeg.c和transupp.c附加到LIB_SOURCES标记中。也许可以尝试对此进行快照:可能是
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
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
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