在 VC 中編譯 IJG JPEG 函數庫

第一步:修改一些IGC源文件

/******************* Changes to jpeglib.h **************************/
#ifndef JPEGLIB_H
#define JPEGLIB_H

/* HJH modification: added extern "C" { when __cplusplus detected */
#ifdef __cplusplus
extern "C" {
#endif

...

/* near bottom of the file */
/* HJH modification: add closing } for extern "C" {  */
#ifdef __cplusplus
}
#endif

#endif /* JPEGLIB_H */

/******************* Changes to jmorecfg.h **************************/
/* jmorecfg.h line 160 */
/* X11/xmd.h correctly defines INT32 */
/* HJH modification: jmorecfg.h already contained a test for XMD_H and xmd.h
   My change adds a test for _BASETSD_H_ because the windows header file
   basestd.h already defines INT32 */
#if !defined(XMD_H) && !defined(_BASETSD_H_)
typedef long INT32;
#endif

/* jmorecfg.h line 220 */
/* HJH modification: several of the windows header files already define FAR
   because of this, the code below was changed so that it only tinkers with
   the FAR define if FAR is still undefined */
#ifndef FAR
  #ifdef NEED_FAR_POINTERS
  #define FAR  far
  #else
  #define FAR
  #endif
#endif
最後需要修改jconfig.h文件
/* HJH Note: Here is one key addition that I had to make. The jpeg library uses
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; #endif #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */

* a type called boolean. It defines boolean here. However, RPCNDR.H * yet another Microsoft header, also defines boolean. The ifndef * ensures that we don't attempt to redefine boolean if rpcndr.h has * already defined it. Note that we use unsigned char instead of int * like jmorecfg.h does, because we want to match what's in the SDK * header. See jconfig.vc for more info, it does the same thing. */

第二步:編譯(來自IGP解壓後的文件夾中的install.doc):
1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and
   makeapps.ds to apps.mak. (Note that the renaming is critical!)
2. Click on the .mak files to construct project workspaces.
   (If you are using DevStudio more recent than 4.2, you'll probably
   get a message saying that the makefiles are being updated.)
3. Build the
libr
ary project, then the applications project.
4. Move the application .exe files from `app`/Release to an
   appropriate location on your path.
5. To perform the self-test, execute the command line
    NMAKE /f makefile.vc test
實際上只需要執行前三步就可以。在release文件夾中可以得到最後編譯的結果jpeg.lib庫文件。

第三步:在自己的代碼中包含
#pragma comment(lib, "jpeg.lib")

#i nclude "jpeglib.h"

Done!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章