开源opensc工程windows平台下编译

在Google上搜了一下opensc的简介,没有,算了还是自己说吧。
opensc官方网站http://www.opensc-project.org/
工程简介:对于智能卡的访问,opensc工程提供了一套库和工具。opensc重点放在了卡片的密码操作,推进卡片的应用如邮件加密、认证和签名。opensc实现了PKCS#11的API以便支持Mozilla FireFox(浏览器)和Thunderbird(邮件客户端)能使用它。opensc实现了PKCS#15标准以便兼容所有的应用。
opensc支持以下卡片:

National ID CardsSmart CardsUSB Tokens二、编译环境
操作系统:Windows XP SP3
开发工具:vistual studio 2003 sp1
代码:opensc-0.11.6.tar.gz
库:openssl 0.9.7e.tar.gz、libtool-1.5.26-bin.zip

三、编译过程
libtool:把zip包解压至c:\(或者别的目录)下
openssl:把tar.gz包解压至c:\下,编译之,步骤略(google上有很多在windows下编译openssl的例子)
opensc:把tar.gz包解压至c:\下,编辑 win32/Make.rules.mak。下面贴出编辑好的文件:

# Note: these instructions obsolete the instructions in opensc.html
# You first need to download the gnuwin32 libtool (e.g. the "Binaries" and "Developer
# files" from http://gnuwin32.sourceforge.net/packages/libtool.htm)
# Then fill in the directory path to ltdl.h on the LIBLTDL_INCL line below, preceeded
# by an "/I"; and fill in the path to the libltdl.lib on the LIBLTDL_LIB line below.
# Then you can build this OpenSC package; and afterwards you'll need to copy the
# libltdl3.dll somewhere on your execution path.
LIBLTDL_INCL = /IC:\libtool-1.5.26-bin\include    # E.g. /IC:\libtool-1.5.8-lib\include (这里改成你自己的路径,我的是c盘)
LIBLTDL_LIB = C:\libtool-1.5.26-bin\lib\ltdl.lib    # E.g. C:\libtool-1.5.8-lib\lib\libltdl.lib(这里改成你自己的路径,我的是c盘)

OPENSC_FEATURES = pcsc
# If you want support for OpenSSL (needed for a.o. pkcs15-init tool and openssl engine):
# - download and build OpenSSL
# - uncomment the line starting with OPENSSL_DEF
# - set the OPENSSL_INCL_DIR below to your openssl include directory, preceded by "/I"
# - set the OPENSSL_LIB below to your openssl lib file
OPENSSL_DEF = /DENABLE_OPENSSL  #把这个选项打开,源代码中使用了openssl,不然会报错
!IF "$(OPENSSL_DEF)" == "/DENABLE_OPENSSL"
OPENSSL_INCL_DIR = /IE:\软件\加密库\openssl\openssl-0.9.7c\include      #改这里的路径
OPENSSL_LIB = E:\软件\加密库\openssl\openssl-0.9.7c\out32dll\Debug\libeay32.lib #指向编译好的libeay32.lib
PROGRAMS_OPENSSL = pkcs15-init.exe cryptoflex-tool.exe netkey-tool.exe piv-tool.exe
OPENSC_FEATURES = $(OPENSC_FEATURES) openssl
!ENDIF

# If you want support for zlib (Used for PIV, infocamere and actalis:
# - Download zlib and build
# - uncomment the line starting with ZLIB_DEF
# - set the ZLIB_INCL_DIR below to the zlib include lib proceeded by "/I"
# - set the ZLIB_LIB  below to your zlib lib file
#ZLIB_DEF = /DENABLE_ZLIB
!IF "$(ZLIB_DEF)" == "/DENABLE_ZLIB"
ZLIB_INCL_DIR = /IC:\ZLIB\INCLUDE
ZLIB_LIB = C:\ZLIB\LIB\zlib.lib
OPENSC_FEATURES = $(OPENSC_FEATURES) zlib
!ENDIF


COPTS = /D_CRT_SECURE_NO_DEPRECATE /Zi /MD /nologo /DHAVE_CONFIG_H /I$(TOPDIR)\src\include /I$(TOPDIR)\src\include\opensc /I$(TOPDIR)\src\common $(OPENSSL_INCL_DIR) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) /D_WIN32_WINNT=0x0400 /DWIN32_LEAN_AND_MEAN $(OPENSSL_DEF) $(ZLIB_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86

install-headers:
@for %i in ( $(HEADERS) ) do \
  @xcopy /d /q /y %i $(HEADERSDIR) > nul
install-headers-dir:
@for %i in ( $(HEADERSDIRFROM2) ) do \
  @xcopy /d /q /y %i\*.h $(HEADERSDIR2)\*.h > nul
.c.obj::
cl $(COPTS) /c $<
.rc.res::
rc /l 0x0409 /r $<
clean::
del /Q *.obj *.dll *.exe *.pdb *.lib *.def

打开vistudio studio .net 2003 command prompt 窗口,然后在opensc根目录下执行 nmake -f Makefile.mak,编译成功!





(文/adylee  出处/博客园)

 感谢原创者的辛勤劳动,希望对您有所帮助,转载请注明原出处。
 您可能对 [Visual Studio.NET] 的这些文章也感兴趣:

Windows Mobile 6.0 SDK及开发体验(二:使用 SqlCe )
使用Vs2005打造简单分页浏览器
.Net Compact Framework 基础篇之自动启动应用程序
Windows Workflow Foundation 之旅---(3)工作流宿主
Phoenix编译器框架说明
基于.NET精简框架的EQATEC代码剖析器1.2版增加新特性
NET4.0 CTP 中的WF
Visual Studio Hotfixes - Still a Mess
.net程序中资源文件的保护办法探讨
框架设计规范的新方向