【问题标题】:Reading JPEG header file in c在c中读取JPEG头文件
【发布时间】:2016-08-02 19:51:09
【问题描述】:

我用 C 语言编写了一个程序来读取 JPEG 文件,如下所示

#include<stdio.h>
#include<jpeglib.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    int height,width,pixel_size;

    FILE *infile = fopen("/home/dbsl/Desktop/Anu/index.jpg", "rb");

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo);
   jpeg_stdio_src(&cinfo, infile);
   jpeg_read_header(&cinfo, TRUE);
   jpeg_start_decompress(&cinfo);

   width = cinfo.output_width;
   height = cinfo.output_height;
   pixel_size = cinfo.output_components;
   printf("Width = %d",width);
   printf("height = %d",height);

   return(1);
}

程序在Fedora20上编译成功。但是当运行执行文件时,它会给出以下错误:

./a.out:加载共享库时出错:libjpeg.so.9:无法打开共享对象文件:没有这样的文件或目录

我不明白是什么问题。

【问题讨论】:

  • No such file or directory你不明白哪一部分?

标签: c header height width jpeg


【解决方案1】:

您的程序使用共享库 (libjpeg.so.9)。当你运行你的程序时,这个库是由ld.so(8) 加载的。所以你必须有这个文件,ld.so(8) 会尝试找到它。

查看man ld.so 以查看该文件的放置位置(默认路径为 /lib/usr/lib)。

【讨论】:

  • 我试过了,但还是不行。不过现在问题解决了。
猜你喜欢
  • 1970-01-01
  • 2013-05-23
  • 1970-01-01
  • 1970-01-01
  • 2010-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-14
相关资源
最近更新 更多