参考博文:
libiconv源码下载地址:
目前最新版本为1.15,将下载的libiconv-1.15.tar.gz解压后得到libiconv-1.15
新建Win32工程,名称为libiconv,应用类型为DLL,附加选项为空工程,点击完成
将libiconv-1.15\lib中的relocatable.h、relocatable.c、iconv.c复制到libiconv\libiconv
复制libiconv-1.15\libcharset\lib\localcharset.c到libiconv\libiconv
复制libiconv-1.15\libcharset\include\localcharset.h.build.in到libiconv\libiconv,将其重命名为localcharset.h
在libiconv中创建文件夹include
复制libiconv-1.15\include\iconv.h.build.in到libiconv\include,将其重命名为iconv.h
复制libiconv-1.15\config.h.in到libiconv\include,将其重命名为config.h
复制libiconv-1.15\lib中的所有头文件(*.h)和定义文件(*.def)到libiconv\include
将libiconv\libiconv中的所有源文件和头文件添加到工程中
注释localcharset.c中的代码
/* Get LIBDIR. */
//#ifndef LIBDIR//# include "configmake.h"//#endif修改iconv.c中的ICONV_CONST为const
在localcharset.h中注释并添加代码
//#if @HAVE_VISIBILITY@ && BUILDING_LIBCHARSET
//#define LIBCHARSET_DLL_EXPORTED __attribute__((__visibility__("default")))//#else//#define LIBCHARSET_DLL_EXPORTED//#endif#ifdef BUILDING_LIBCHARSET#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)#elif USING_STATIC_LIBICONV#define LIBCHARSET_DLL_EXPORTED#else#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)#endif注释config.h中的代码
/* Define as good substitute value for EILSEQ. */
//#undef EILSEQ在iconv.h中注释并添加代码
//#if @HAVE_WCHAR_T@#if HAVE_WCHAR_T
//#if @USE_MBSTATE_T@#if USE_MBSTATE_T
//#if @USE_MBSTATE_T@//#if @BROKEN_WCHAR_H@#if USE_MBSTATE_T#if BROKEN_WCHAR_H
//extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, @ICONV_CONST@ char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);extern LIBICONV_DLL_EXPORTED size_t iconv(iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
/*#if @HAVE_VISIBILITY@ && BUILDING_LIBICONV#define LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default")))#else#define LIBICONV_DLL_EXPORTED#endifextern LIBICONV_DLL_EXPORTED @DLL_VARIABLE@ int _libiconv_version;*/ /* Likewise */#if BUILDING_LIBICONV#define LIBICONV_DLL_EXPORTED __declspec(dllexport)#elif USING_STATIC_LIBICONV#define LIBICONV_DLL_EXPORTED#else#define LIBICONV_DLL_EXPORTED __declspec(dllimport)#endifextern LIBICONV_DLL_EXPORTED int _libiconv_version;
进入工程属性->VC++目录,在包含目录中添加$(SolutionDir)include
构建工程即可得到库文件libiconv.dll、libiconv.lib