Recently, zeroc officially released the latest version of ice 3.3.1. I have also compiled it completely, including the compilation of the third-party libraries IT uses. Now, the compilation process is recorded here.
Compilation environment and code download
This compilation is based on the Win32 platform in intel X86 architecture. It uses Microsoft Visual stuido 2005, and the C ++ compiler is msvc 8.0.
On the zeroc official website, we can download the source code package of ice. I have prepared to compile from the source code completely, so I need the following two packages:
- Ice-3.3.1.zip-this package includes source code for all the languages of ice
- ThirdParty-Sources-3.3.1.zip (Windows)-This package contains the source code for all third-party libraries used by ice
Starting from ice 3.3.0, We don't prepare source code packages for various languages separately, but pack the code of all languages into a large package, so if we open the Ice-3.3.1.zip package, the subdirectories correspond to C ++, C #, Java, PHP, Python, Ruby, and VB respectively. If you need to know the detailed compilation and installation instructions, you need to enter the subdirectory of the corresponding language, and then read the install file.
In the source code package of a third-party library, the source codes of various supported libraries are: bzip, Berkeley dB, forms, looks, MCPP, OpenSSL, stlport, and expat. Since msvc 8.0 is used, stlport is not needed, and I only want to compile the C ++ environment, so I will only use the following libraries: bzip, Berkeley dB, MCPP, OpenSSL, and expat.
Prepare tools and environment
As the saying goes: Do not cut the firewood by mistake. I also recommend some useful tools before compilation.
The first is rapid environment Editor, which is a tool used to edit environment variables. During the development process, environment variables can provide us with great convenience. For example, we can put the search paths of all header files in the include environment variables, place the library file path in the Lib environment variable. However, the environment variable editing provided by Windows by default is too difficult to use, so we recommend using this tool to make our compilation life more comfortable.
When using this environment variable Editor, we recommend that you add all the environment variables you have defined to the user part without affecting the system part (that is, the right side of the editor ). We recommend that you add the following environment variables: path, include, and Lib. Every time we change the environment variables, we need to save the changes, and then restart our command line window to make the changes take effect.
The second tool is active Perl, because OpenSSL compilation requires Perl for Environment configuration. You can directly download and install Perl on its homepage. During the installation process, you will be prompted whether to add Perl to your path variable. Of course, select YES.
The third tool is Python, which is mainly used to run the ice test program.
The fourth tool is Ant and Java, which must be used during ice installation. To install this tool, we first need to download JRE or JDK from java.sun.com, and then download the ant tool from the ant website. This tool is a green tool (Java program ), decompress the package to your hard disk and set the bin path to the path environment variable.
The last tool is patch. We chose the patch tool in the gnuwin32 project. After installation, We need to manually add the bin directory to our path variable. Generally, the directory is c: \ Program Files \ gnuwin32 \ bin.
The tool is ready. We need to plan the directory structure. For ease of use, ice requires two directories:
Ice-3.3.1-ThirdParty-VC80
-If this directory contains files from third-party libraries, we need to create three subdirectories: Bin, include, and Lib for future convenience, we can add these three subdirectories to our path, include, and Lib environment variables respectively. Note the directory name: Ice-$ (Version)-thirdparty-$ (cpp_compiler)
Ice-3.3.1-VC80
-We do not need to create this directory in advance. We will set the installation path of ice to this directory. At that time, all the required files will be copied to this directory, and bin, include, will also be created under it, lib three subdirectories. If we put these three subdirectories into the corresponding environment variables, it will be more convenient to use ice later. Its naming method is: Ice-$ (Version)-$ (cpp_compiler)
Well, the environment is almost ready. Next we will compile it. All the compilation methods use the command line method (except the DB compilation), so we need to use the visual stuido command line window.
Compile MCPP
In the ThirdParty-Sources-3.3.1.zip package, extract the mcpp-2.7.2.zip to a temporary directory and then:
] cd mpp-2.7.2\src] patch -p0 < ..\noconfig\vc2005.dif] nmake MCPP_LIB=1 /f ..\noconfig\visualc.mak mcpplib
Then, copy the file:
- Mpp-2.7.2 \ SRC \ MCPP. Lib =>$ (3 Party) \ Lib
Compile bzlib
In the ThirdParty-Sources-3.3.1.zip package, unzip the bzip2-1.0.5.tar.gz to a temporary directory, and decompress the Bzip2 directory to the temporary directory of the same level, which contains patches and modified makefiles. Then:
] cd bzip2-1.0.5] patch -p0 bzlib.h < ..\bzip2\bzlib.patch] nmake /f ..\bzip2\Makefile.mak
Then, copy the file:
- Bzip2-1.0.5 \ bzlib. H = >$ (3 Party) \ include
- Bzip2-1.0.5 \ bzip2.dll =>$ (3 Party) \ bin
- Bzip2-1.0.5 \ libbz2.lib =>$ (3 Party) \ Lib
Install expat
For the expat library, the thirdparty-sources package provides the installation program. We will execute it directly and create the expat 2.0.1 directory in the Program Files directory. We will go to this directory and copy the file directly:
- Bin \ libexpat. dll =>$ (3 Party) \ bin
- Bin \ libexpat. Lib =>$ (3 Party) \ Lib
- Source \ Lib \ expat. h =>$ (3 Party) \ include
- Source \ Lib \ expat_external.h =>$ (3 Party) \ include
Compile OpenSSL
Decompress the openssl-0.9.8g.tar.gz in the thirdparty-sources package to the temporary directory, and then alignment for compilation. This requires Perl and the assembly compiler, and MASM should be included in our visual stuido 2005, so there is no need to reinstall, you can call ml to check whether the compiler exists. The compilation process is as follows:
] cd openssl-0.9.8g] perl Configure VC-WIN32 --prefix=C:/openssl-tmp] ms\do_masm] nmake /f ms\ntdll.mak] nmake /f ms\ntdll.mak test] nmake /f ms\ntdll.mak install
Note: When prefix is entered, the directory separator must use the backslash '/'. If '\' is used, an error is returned during compilation.
The include, bin, and Lib directories are also generated in the installation directory (C: \ OpenSSL-TMP, overwrite these three directories to our $(3 Party) directory.
Compile Berkeley DB
Decompress the db-4.6.21.NC.zip in the thirdparty-sources package to the temporary directory, and extract the patch files under the DB directory in the package to the db-4.6.21.NC directory, and then execute:
] cd db-4.6.21.NC] patch --binary -p0 < patch.4.6.21.1] patch --binary -p0 < patch.4.6.21.2] patch --binary -p0 < patch.4.6.21.3] patch --binary -p0 < patch.4.6.21.15663
Note: During patching, we need to use--binary
Otherwise, the patch fails.
Next, use visual stuido's ide for compilation: Enter the build_windows subdirectory and open the solution file berkeley_db.dsw. This is an old project file, so you will be asked if you want to convert, select "yes", select the "Release x86" we need from the compilation configuration, right click on the build_all project, select "build" to complete the compilation.
After compilation, copy the file:
- Build_windows \ dB. h =>$ (3 Party) \ include
- Build_windows \ db_cxx.h =>$ (3 Party) \ include
- Build_windows \ release \ libdb46.lib =>$ (3 Party) \ Lib
- Build_windows \ release \ libdb46.dll =>$ (3 Party) \ bin
- Build_windows \ release \ *. EXE =>$ (3 Party) \ bin
Start to compile ice
The support library is finally compiled (these are only required by the C ++ Environment). Let's start to compile the ice library.
Decompress ice-3.3.1 to the temporary directory and edit the Ice-3.3.1 \ CPP \ config \ make. Rules. Make file:
## Select an installation base directory. The directory will be created# if it does not exist.#prefix = E:\win\lib\Ice-$(VERSION)-VC80## Define OPTIMIZE as yes if you want to build with# optimization. Otherwise Ice is build with debug information.#OPTIMIZE = yes## Specify your C++ compiler. Supported values are:# VC60, VC80, VC80_EXPRESS, VC90, VC90_EXPRESS, BCC2007, BCC2009#!if "$(CPP_COMPILER)" == ""CPP_COMPILER= VC80!endif## If third party libraries are not installed in the default location# or THIRDPARTY_HOME is not set in your environment variables then# change the following setting to reflect the installation location.#!if "$(CPP_COMPILER)" == "VC80_EXPRESS"THIRDPARTY_HOME_EXT= VC80!elseif "$(CPP_COMPILER)" == "VC90_EXPRESS"THIRDPARTY_HOME_EXT= VC90!elseTHIRDPARTY_HOME_EXT= $(CPP_COMPILER)!endif!if "$(THIRDPARTY_HOME)" == ""THIRDPARTY_HOME = E:\win\lib\Ice-$(VERSION)-ThirdParty-$(THIRDPARTY_HOME_EXT)!endif## For VC80 it is necessary to set the location of the manifest tool.# This must be the 6.x version of mt.exe, not the 5.x # version!#!if "$(CPP_COMPILER)" == "VC80"MT = "$(VS80COMNTOOLS)bin\mt.exe"!elseMT = mt.exe!endif
Three configurations are modified: The third-party library directory, the installed directory, and whether to enable release version compilation.
After the bin, include, and Lib directories of third-party libraries are set to path, include, and Lib environment variables, run:
] cd Ice-3.3.1\cpp] nmake /f Makefile.mak] allTests.py] nmake /f Makefile.mak install
Note: I encountered an exception when executing alltests. py. It is not clear what is going on, but it does not affect usage. The ant tool will be used during installation, so you need to install Java + ant first. Refer to the previous section on tool preparation.
So far, the C ++ environment of ice 3.3.1 has been compiled and installed. We need to put the ice-3.3.1 and the third-party library's bin, include, and Lib Paths into path, include, in the Lib environment variable, you can use ice 3.3.1 of C ++.
You can use the environment variable editor software to manage your environment, making it easy to set up the environment:
From the old blog http://blog.ipattern.org/archives/874