代码在github:https://github.com/langresser/iconv1.14-for-vs2010
参考这篇文章:http://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio
摘录如下:
Introduction
Libiconv
is one of the most useful and famous libraries that converts texts between encodings and has been developed under GNU projects. However, now it does not provide the way to build it with Microsoft Visual Studio but with gcc. Before, it had provided but now stopped explaining how to build it with Microsoft Visual Studio. However, many of the computer programmers are using Microsoft Visual Studio and want to build libiconv
with Microsoft Visual Studio. So, this article is about how to build libiconv
with Microsoft Visual Studio. If you can buildlibiconv
with Microsoft Visual Studio, you will be able to change various compilation options and build it in order to optimize libiconv
according to your preference and needs.
Background
If you have no idea about libiconv
, you can refer to it here or you can Google for it. You may be confused withiconv
and libiconv
. Iconv
is the executable program that uses libiconv
while libiconv
is the library for converting text strings between two different encodings. This article is related to libiconv
. However, this article is not about libiconv
but about how to build libiconv
with Microsoft Visual Studio. The GNU library libiconv
is under LGPL license. So, you have to be really careful when you use libiconv
for your commercial use or when you don't want to publicize your source code. About LPGL license, you can refer here.
How to Get the Source Code of libiconv
At the moment, the most recent version of libiconv
is 1.14. You can download the source code of libiconv
1.14 here and here. Of course, you can get the older versions of libiconv
here.
How to Build
I am going to explain the case of Microsoft Visual Studio 2010 professional edition but the explanation can be applied to the earlier versions of Microsoft Visual Studio and to the express edition of each of them.
First Step
You download the most recent version of libiconv
which is 1.14 from here or here. And unzip the downloaded file "libiconv-1.14.tar.gz" on your certain folder.
Second Step
You run your Microsoft Visual Studio. Then, you make a new WIN32
project. Let's say "libiconv
" as the project name. Check to create directory for solution. Choose DLL as the application type and check Empty project for additional options. Click the button "finish" to generate the new project.
Third Step
Now, you have to copy some files from the folders generated by unzipping "libiconv-1.14.tar.gz" to the project folders. To build "libiconv
", you need to compile three files "localcharset.c", "relocatable.c" and "iconv.c". That is the key idea!
Copy three files "relocatable.h", "relocatable.c" and "iconv.c" in the folder "...\libiconv-1.14\lib\" to the project folder "...\libiconv\libiconv\".
Copy "...\libiconv-1.14\libcharset\lib\localcharset.c" to the project folder "...\libiconv\libiconv\".
Copy "...\libiconv-1.14\libcharset\include\localcharset.h.build.in" to the project folder "...\libiconv\libiconv\" and then, rename the copied "localcharset.h.build.in" to "localcharset.h.
Copy "...\libiconv-1.14\windows\libiconv.rc" to the project folder "...\libiconv\libiconv\".
Make folder "include" under the project folder "...\libiconv\" so to make "...\libiconv\include".
Copy "...\libiconv-1.14\include\iconv.h.build.in" to the project include folder "...\libiconv\include" and then, rename the copied "iconv.h.build.in" to "iconv.h".
Copy "...\libiconv-1.14\config.h.in" to the project include folder "...\libiconv\include" and then, rename the copied "c