如何包含< stdio.h>在jpeglib.h(jpeg-8c)中 [英] How do I include <stdio.h> in jpeglib.h (jpeg-8c)

查看:73
本文介绍了如何包含< stdio.h>在jpeglib.h(jpeg-8c)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用c ++编辑一些jpeg文件.我链接到libjpg并编译了我的代码.编译器抱怨typedefs FILE和size_t.我搜索了这个问题,发现该库旨在在C而不是C ++下编译,因此我们必须手动将include stdio.h添加到"jpeglib.h"中.我这样做了,但是这次编译器给了我以下错误:

I want to edit some jpeg files with c++. I linked to libjpg and compiled my code. Compiler complained about typedefs FILE and size_t. I googled the problem and found out that this library is designed to compile under C not C++ so we have to manually add include stdio.h to "jpeglib.h". I did that but this time compiler gave me the folloeing errors:

undefined reference to `jpeg_CreateCompress'    JPGImage.cpp    /KFCK/src   line 47 C/C++ Problem
undefined reference to `jpeg_CreateDecompress'  JPGImage.cpp    /KFCK/src   line 92 C/C++ Problem
undefined reference to `jpeg_destroy_compress'  JPGImage.cpp    /KFCK/src   line 77 C/C++ Problem
undefined reference to `jpeg_destroy_decompress'    JPGImage.cpp    /KFCK/src   line 123    C/C++ Problem
undefined reference to `jpeg_finish_compress'   JPGImage.cpp    /KFCK/src   line 74 C/C++ Problem
undefined reference to `jpeg_finish_decompress' JPGImage.cpp    /KFCK/src   line 120    C/C++ Problem
undefined reference to `jpeg_read_header'   JPGImage.cpp    /KFCK/src   line 102    C/C++ Problem
undefined reference to `jpeg_read_scanlines'    JPGImage.cpp    /KFCK/src   line 115    C/C++ Problem
undefined reference to `jpeg_set_defaults'  JPGImage.cpp    /KFCK/src   line 61 C/C++ Problem
undefined reference to `jpeg_set_quality'   JPGImage.cpp    /KFCK/src   line 62 C/C++ Problem
undefined reference to `jpeg_start_compress'    JPGImage.cpp    /KFCK/src   line 65 C/C++ Problem
undefined reference to `jpeg_start_decompress'  JPGImage.cpp    /KFCK/src   line 104    C/C++ Problem

找不到库函数.如果删除stdio.h行并再次编译,则会得到以下信息:

It can't find the library functions. If I delete the stdio.h line and compile again I get this:

‘FILE’ has not been declared    KFCK        line 956, external location: /home/../jpeg-8c/jpeglib.h C/C++ Problem
‘FILE’ has not been declared    KFCK        line 957, external location: /home/../jpeg-8c/jpeglib.h C/C++ Problem
‘size_t’ does not name a type   KFCK        line 756, external location: /home/../jpeg-8c/jpeglib.h C/C++ Problem
‘size_t’ does not name a type   KFCK        line 768, external location: /home/../jpeg-8c/jpeglib.h C/C++ Problem
‘size_t’ has not been declared  KFCK        line 799, external location: /home/../jpeg-

我该怎么办?

推荐答案

放回#include.但是看起来很像在链接时未添加-ljpeg或类似内容.另外,您还需要确保如果要在C ++代码中包含此代码,则可能需要这样做:

Put the #include back. But it looks awfully like you are not adding a -ljpeg or something similar when you are linking. Also you need to make sure that if you are including this in C++ code you may need to do:

extern "C" {
#include <jpeglib.h>
}

这篇关于如何包含&lt; stdio.h&gt;在jpeglib.h(jpeg-8c)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆