Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

ICU(1) Compile ICU Unicode library with VC++ of old version

Published on| October 1st, 2009 | No Comment.
Summary:
This time, ICU is. It is also very famous UNICODE libraries.
ICU is, UNICODE is a library for handling. Has cross-platform, Linux on the UNICODE system control is being used as well. In addition, BOOST other libraries, such as in dealing with UNICODE, in general are often linked to ICU.

The latest version of ICU, VC + + support for the latest version of the (project file) is done only. Therefore, VC + + If you compile the latest version is the only good solution to build the open.
(% ICU installation directory% \ icu \ source \ allinone \ allinone.sln)

However, the old VC + +, compile (install) If you do, you need a little more effort.

This time, leave the settings described in that environment.

Download

Sample source code you used here:


Have justified what they need, compile
Requirements

The following is required.
Before you compile, and prepare everything.
  • VC + + 2003, 2005 is required either.
    2003, ToolKit + Standard or a combination of things that can be optimized揃Emashou higher edition.
  • Cygwin
    From where to download the mind mechanism, Setup.exe Download.

    Setup.exe to start the installation begins.
    Make a note described a simple point.
    This feature requires, bash and make are two.

    1. "Next" button.

    2. "Install from Internet ..." and then check.
      ※ download and install the latest files from the Internet as needed.
      "Next" button.

    3. Specify the installation directory.
      (Installation directory name is blank or "-" sign is safe and there is no better. )

      Default file format used in "DOS ..." set.
      ※ ICU files, the same as Windows CRLF line code has become. I get a strange error unless you set here.

      After the set, "Next" button.


    4. Specify the directory containing the downloaded file.
      When you are satisfied with the default settings directory, I better go away.
      After the set, "Next" button.


    5. Default "Direct ..." and specify the "Next" button.


    6. Identify sites to download.
      I live in hell my country site will be better specified site.
      For example, you, if the Japanese, "xxxx.jp" It is better specified site.


    7. Here, "Devel" in the hierarchy of "make: The GNU ..." and then locate the check.
      (By default, so Skip is not installed. )


    8. Running the screen to download and install.


    9. "Finish button" is complete, click.



  • ICU source from which you downloaded the first set, icu4c-4_xxx-src.zip to download the file and unzip to the directory without installation.

Cygwin is, bash will be installed by default, make is not installed so, should I have to specify as above.

Configuration and compilation (build)

Sorottara what you need as described above, the following steps, perform the compilation.

  1. VC + + 2003, 2005 to start the command prompt either.
  2. Started from the command prompt, Cygwin to set the path.
    1
    2
    
    C:\> set path=%path%;c:\cygwin\bin
    C:\> 

    In this example, cygwin is installed in "c: \ cygwin" and is.
    ※ cygwin path, let's add at the end.
  3. Started from the command prompt, Arciver the path of the command set as the path to Cygwin.
    1
    2
    
    C:\> set AR=c:\cygwin\bin
    C:\> 

    In this example, cygwin is installed in "c: \ cygwin" and is.
  4. Change to the directory where you unzipped the ICU.
    1
    2
    3
    
    C:\> cd \ICU
    C:\ICU> cd icu\source
    C:\ICU\icu\source> 

    In this example, ICU is to extract the "c: \ ICU" and is.
    Furthermore, icu \ source Please note that you move to.
  5. ICU to make re-create the file.
    1
    2
    3
    4
    5
    
    C:\ICU\icu\source> bash ./runConfigureICU Cygwin/MSVC
                       :
                       :
                       :
    C:\ICU\icu\source> 

    In this example, VC + +2003 commands in the image.
    VC + +2005 If you are using, "Cygwin/MSVC2005" is specified.

    Without the error, especially in view here is OK.
  6. Created to make the build file.
    1
    2
    3
    4
    5
    
    C:\ICU\icu\source> make
                       :
                       :
                       :
    C:\ICU\icu\source> 

    Make command here, Cygwin installed with GNU Make should not be otherwise.
    If the behavior is wrong, let's make a separate check for other environments is not working.

    Without the environment are made, especially in view of the error here.

If an error occurs so far, there is an error in your own environment.
For example, mingw is a combination of such cases, such as Cygwin correctly and the impact it has no command is executed, if an error occurred, first, the environment (especially PATH) Let's review.

Prepare a development
To use the ICU, Include and Library path to the path, ICU must add the path of each.
Here, ICU has been created in the DLL (icu \ source \ lib Please check). Therefore, preferences, PATH and add the path to the DLL is located.


This time, VC + + 2003 uses the IDE, so let's go to the Preferences.

  1. Bring up the VC + + 2003
  2. The Tools menu - Options - Project - [VC + + Directories Open.


    Here,
    "Include" a, "C: \ ICU \ icu \ source \ common" add.
    "Library files", "executable" to, "C: \ ICU \ icu \ source \ lib" to add.

After the set, OK button.

Let's build a VC + + sample.

Created in VC + + project to create a blank console application.
Paste the following source code to the project to create a cpp file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <iostream>
#include <unicode/ucnv.h>
 
using namespace std;
 
 
// ライブラリを指定しておく
#pragma comment(lib, "icuuc.lib")
 
 
int main()
{
	const wchar_t *porg=L"テスト日本語のテスト、UNICODEからShiftJis!!";
 
	UErrorCode	error = U_ZERO_ERROR;
 
	int nosize=(int )wcslen(porg);
	int ndsize=nosize*2+sizeof(int);
 
	char *abuff=new char[ndsize];
 
	int ncsize = ucnv_convert(
		"shift_jis","utf-16le",abuff,ndsize,(const char *)porg,nosize*2,&error);
 
	cout << abuff << endl;
 
	delete []abuff;
 
	return 1;
}

Now, please try to build.
If compilation and linking is completed, OK is.
If you can not compile the above code is incorrect for the environment. Please review the environmental path.

Above program is as follows adjournment and the console actually work, so if you see garbage characters instead of following it is OK.

1
テスト日本語のテスト、UNICODEからShiftJis!!


Now, VC + + version of the previous (2003 and earlier versions are not compiled) will be available at the ICU. Other colors are available in many libraries ICU so once you would also be a good try.


Comments

Leave a Reply







  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ