VC6下编译IJG库
IJG 是什么?
IJG 是一个处理 jpeg 的 C 语言写的库,其官方站点是 http://www.ijg.org/。
http://www.ijg.org/ 写道
Independent JPEG Group
IJG is an informal group that writes and distributes a widely used free library for JPEG image compression. The first version was released on 7-Oct-1991.
The current version is release 8d of 15-Jan-2012. This is a stable and solid foundation for many application's JPEG support.
You can find our code and some supporting documentation in the directory files. There is a Unix format package in tar.gz archive format jpegsrc.v8d.tar.gz and a Windows format package in zip archive format jpegsr8d.zip.
To learn more about how to use JPEG, see the JPEG FAQ. If you'd like to learn about how JPEG works, start with the comp.compression FAQ.
The ISO/IEC JTC1/SC29/WG1 standards committee (also known as JPEG, together with ITU-T SG16) has their own web site. IJG is not affiliated with the ISO committee.
IJG development continues. Advanced features are being prepared for coming releases...
Version 9 of the Independent JPEG Group software is currently in development and is planned for release in January 2013. The development site for IJG JPEG 9 is at InfAI.org.
怎么编译 jpeg.lib ?
下载 jpegsr8d.zip 文件之后解压,打开其中的 install.txt 文件,找到文件末尾的关于 VC6 的编译指令说明,如下:
install.txt 写道
Microsoft Windows, Microsoft Visual C++ 6 Developer Studio:
We include makefiles that should work as project files in DevStudio 6.0 or
later. There is a library makefile that builds the IJG library as a static
Win32 library, and application makefiles that build the sample applications
as Win32 console applications. (Even if you only want the library, we
recommend building the applications so that you can run the self-test.)
To use:
1. Open the command prompt, change to the main directory and execute the
command line
NMAKE /f makefile.vc setup-vc6
This will move jconfig.vc to jconfig.h and makefiles to project files.
(Note that the renaming is critical!)
2. Open the workspace file jpeg.dsw, build the library project.
(If you are using DevStudio more recent than 6.0, you'll probably
get a message saying that the project files are being updated.)
3. Open the workspace file apps.dsw, build the application projects.
4. To perform the self-test, execute the command line
NMAKE /f makefile.vc test-build
5. Move the application .exe files from `app`\Release to an
appropriate location on your path.
D:\test\jpegsr8d\jpeg-8d>NMAKE /f makefile.vc setup-vc6
Microsoft (R) Program Maintenance Utility Version 6.00.8168.
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
ren jconfig.vc jconfig.h
ren makejdsw.vc6 jpeg.dsw
ren makeadsw.vc6 apps.dsw
ren makejmak.vc6 jpeg.mak
ren makejdep.vc6 jpeg.dep
ren makejdsp.vc6 jpeg.dsp
ren makecmak.vc6 cjpeg.mak
ren makecdep.vc6 cjpeg.dep
ren makecdsp.vc6 cjpeg.dsp
ren makedmak.vc6 djpeg.mak
ren makeddep.vc6 djpeg.dep
ren makeddsp.vc6 djpeg.dsp
ren maketmak.vc6 jpegtran.mak
ren maketdep.vc6 jpegtran.dep
ren maketdsp.vc6 jpegtran.dsp
ren makermak.vc6 rdjpgcom.mak
ren makerdep.vc6 rdjpgcom.dep
ren makerdsp.vc6 rdjpgcom.dsp
ren makewmak.vc6 wrjpgcom.mak
ren makewdep.vc6 wrjpgcom.dep
ren makewdsp.vc6 wrjpgcom.dsp
D:\test\jpegsr8d\jpeg-8d>
上面的步骤会在源程序目录中生成很多 dsp 和 dsw 文件,选择其中的 jpeg.dsw 用 VC6 打开。
编译之后就会在 Release 目录生成 jpeg.lib 静态库文件。
怎样在 VC6 中使用 IJG 的 jpeg 库?
为了方便以后使用,可创建一个名为 libjpeg 的目录,将下列文件复制到其中:
jpeg.lib
jpeglib.h
jconfig.h
jmorecfg.h
以后在使用的时候就只需要将 libjpeg 目录复制到工程所在目录中,与 jpeg-8d 下一大堆文件无关了。
在使用时,使用到该库的 cpp 文件应加上如下内容:
extern "C" {
#include "jpeglib.h"
}
#pragma comment(lib, "libjpeg/jpeg.lib")
因为那些头文件是放置在 libjpeg 目录中的,因此需要增加 附加包含路径 libjpeg,操作如下:
在菜单“工程”中选择“设置”,切到“C/C++”,将“分类”选择为“预处理器”,在“附加包含路径”中加入 libjpeg 。
使用时需要 将 MFC 库作为静态库使用,更改方式:
在菜单“工程”中选择“设置”,切到“常规”,就会看到 Microsoft 基础类的设置,改成“把MFC作为静态链接库”。
否则,在链接时报一大堆错误
编译连接出错信息 写道
Linking...
libcmt.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
libcmt.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
libcmt.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
libcmt.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
msvcrtd.lib(cinitexe.obj) : warning LNK4098: defaultlib "libcmt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
libcmt.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/TestClipboard.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
参考资料
参考资料1:vc++6.0环境下编译使用IJG
http://hi.baidu.com/zhi_qiu_yi_ye/blog/item/7d367f27704aa75f9922ed05.html
参考资料2:利用IJG JPEG Library压缩图像为jpg格式
http://www.vckbase.com/document/viewdoc/?id=1790
分享到:
相关推荐
在Windows环境下,使用Microsoft Visual Studio 2005(或类似版本)编译IJG库时,需要对源代码进行一些微调。首先,在`jmorecfg.h`文件中取消对`FAR`关键字的定义,并处理`INT32`类型定义,以适应Visual Studio环境...
在本文中,我们将深入探讨如何使用Microsoft Visual C++(简称VC)进行图像编辑程序的开发,特别是基于IJG库处理JPEG和BMP格式的图片。IJG库,全称为Independent JPEG Group Library,是一个广泛使用的开源库,专门...
在VC6.0环境下,开发一个能够读取和写入JPEG文件的应用程序是一项常见的任务,尤其是在处理图像数据或创建图像编辑软件时。本教程将详细解释如何使用VC++ 6.0实现JPEG文件的读写功能,并提供了一个名为"ShowJPEG"的...
1. **引入libjpeg库**:下载并编译libjpeg库,将其头文件和库文件添加到你的VC++项目中。这通常包括`jpeglib.h`、`jerror.h`等头文件和对应的.lib或.dll文件。 2. **读取JPG图像**:利用libjpeg库的API,如`jpeg_...
下载并编译libjpeg库后,将其包含到你的项目中,确保添加相应的头文件和库文件路径。 1. **设置项目配置**: 在VC 6.0中,打开项目属性,配置包含目录以包含libjpeg库的头文件路径,同时配置链接器的输入选项,将...
6. 测试和调试,确保在VC环境下能正确读取和显示JPEG图片。 总之,要在VC中不使用DLL显示JPEG图片,开发者需要对两种编程环境有深入理解,同时熟悉C++和Delphi之间的语法差异,以及如何处理跨语言的库集成。通过这...
在配置过程中,还需要对库文件进行链接。如示例所示,需要在链接选项中排除掉"jpeg.lib"。这是因为libjpeg库在源码中已经以extern方式声明,因此需要确保不与项目中的其他库产生命名冲突。 关于libjpeg的使用,文档...