一、下载jpegsrc
1、下载JPEG库的源代码 http://www.ijg.org/files/
2、这里使用最新的jpegsr9e.zip ,别下载错误了(jpegsrc.v9e.tar.gz 是RAM架构的仅支持32位)
3、解压jpegsr9e.zip到d盘,如:D:\jpeg-9e
二、vs2019编译windows x86(x64)架构的lib库
启动Developer Command Prompt for VS 2019.exe,通过命令进入到D:\jpeg-9e:
CD D:\jpeg-9e
直接使用命令(注意vs2019是setup-v16,其他的版本需要查一下):
NMAKE /f makefile.vc setup-v16
此时在文件夹内出现了jpeg.sln,用vs2019打开,并选择x86或则x64:
编译时需要选择架构类型:
win32和x64代表x86和x64,也可以选择ARM。
于是生成了:
然后通过包含调用lib即可:
#include "jpeglib.h"
大家也可以直接下载vs2019的项目文件:
三、vs2019编译windows ARM架构的lib库
注意如果下错了jpegsrc.v9e.tar.gz ,采用的是ARM架构下的会出现错误:
makefile.vc(11) : fatal error U1052: 未找到文件“win32.mak”
Stop.
此时请将下面的代码通过txt另存为:Win32.Mak,放在D:\jpeg-9e中,然后再执行上面的命令。
# Win32.Mak - Win32 application master NMAKE definitions file for the
# Microsoft Windows SDK programming samples
# Copyright (C) Microsoft Corporation
# -------------------------------------------------------------------------
# This files should be included at the top of all MAKEFILEs as follows:
# !include <Win32.Mak>
# -------------------------------------------------------------------------
#
# Define APPVER = [ 4.0 | 5.0 | 5.01 | 5.02 | 6.0 | 6.1] prior to including win32.mak to get
# build time checking for version dependencies and to mark the executable
# with version information.
#
# Define TARGETOS = [ WIN95 | WINNT | BOTH ] prior to including win32.mak
# to get some build time checking for platform dependencies.
#
# Define TARGETLANG = [ LANG_JAPANESE | LANG_CHINESE | LANG_KOREAN ] prior
# to including win32.mak to getcompile & link flags for building
# applications to run on Far-East Windows. (This is an optional parameter.
# The system locale is the default.)
#
# Define _WIN32_IE = [ 0x0300 | 0x0400 | 0x0500 | 0x0600] prior to including win32.mak to
# get compile and link flags for building applications and components to
# run on Internet Explorer. (This is an optional parameter. IE 4.0 is
# the default.)
#
# -------------------------------------------------------------------------
# NMAKE Options
#
# Use the table below to determine the additional options for NMAKE to
# generate various application debugging, profiling and performance tuning
# information.
#
# Application Information Type Invoke NMAKE
# ---------------------------- ------------
# For No Debugging Info nmake nodebug=1
# For Working Set Tuner Info nmake tune=1
# For Call Attributed Profiling Info nmake profile=1
# For COLE 32->64-bit Porting Tool nmake COLE_64=1
#
# Note: The three options above are mutually exclusive (you may use only
# one to compile/link the application).
#
# Note: creating the environment variables NODEBUG, TUNE, and PROFILE is an
# alternate method to setting these options via the nmake command line.
#
# Note: to use the COLE_64 option, you need to set your build environment
# for 64-bit compilations.
#
# Note: TUNE and PROFILE do nothing for 64bit compilation
#
# Additional NMAKE Options Invoke NMAKE
# ---------------------------- ------------
# For No ANSI NULL Compliance nmake no_ansi=1
# (ANSI NULL is defined as PVOID 0)
#
# =========================================================================
# Build Rules Quick Start
#
# To build one of the following types of executables, use the specified
# compiler and linker command-line options.
#
# ---------------------------------------------------------------------------
# To build: | Compiler Options | Linker options (pick one
# | | line. con = console,
# | | gui = GUI, ole = GUI OLE)
# ---------------------------------------------------------------------------
# Single threaded | cdebug cflags cvars | ldebug guilflags guilibs
# app with static | | ldebug conlflags conlibs
# CRT | | ldebug guilflags olelibs
# ---------------------------------------------------------------------------
# Multithreaded app | cdebug cflags cvarsmt | ldebug guilflags guilibsmt
# with static CRT | | ldebug conlflags conlibsmt
# | | ldebug guilflags olelibsmt
# ------