用Visual-C++安装MICO


(by huihoo.com connect_freeman 翻译 )

Subsections
Prerequisits
Compiling the MICO sources
Writing MICO applications using the IDE

--------------------------------------------------------------------------------

Installing MICO using Visual-C++
Installing MICO under Windows using the Visual-C++ compiler is sufficiently different to dedicate it its own section. Beware that this compiler is not among the technically most solid pieces of engineering and you should make sure that you have applied all Service Packs there are (Microsoft terminology for bug fixes). It is also advisable to check the latest release notes for MICO on the Windows platform which are contained in the file README-WIN32.

Prerequisits
You will need Visual-C++ 5.0 Service Pack 3 or (preferred) Visual-C++ 6.0 Service Pack 2 to compile MICO for Windows. Note that without Service Pack 3 for Visual-C++, you will not be able to compile the sources or write MICO applications. Windows version of flex and bison are not required. The MICO distribution already contains the files generated by these tools. VC++ 5.0 SP3 is available from:

http://www.microsoft.com/msdownload/vs97sp/full.asp

VC++ 6.0 service packs are available at:

http://msdn.microsoft.com/vstudio/sp/default.asp

The Windows 95 implementation of the TCP/IP protocol stack cause problems with MICO applications. You need to download and install the WinSock2 library which fixes these problems. You can download WinSock2 from the Microsoft web server for free:

http://www.microsoft.com/windows95/downloads/contents/wuadmintools/\ s_wunetworkingtools/w95sockets2/default.asp?site=95

IMPORTANT: You also need to make sure that the environment variables are set properly for Visual-C++. There is a batch file called VCVARS32.bat specifically for this purpose. Be sure to run this batch file -- which is part of VC++ -- before you try to compile MICO.

Once you have made sure that your Windows platform meets all the above mentioned prerequisits, you can unpack the MICO sources. The sources are shipped as a zipped archive on the CD called

mico-.zip

Where is the version number of the MICO release contained on the CD. Unpack the archive at the desired location.

Compiling the MICO sources

Change to the directory where you have unzipped the MICO sources and edit the file MakeVars.win32. Set the SRCDIR variable to the location of the MICO directory (no trailing backslash). There is no need to run a configure script. MICO is pre-configured for Windows.

VC++ comes with its own Makefile tool called nmake. Unfortunately this tool is sufficiently incompatible with other make tools. For this reason the MICO distribution contains a second set of Makefiles. These Makefiles have the suffix .win32 and are tailored to work with nmake. To compile MICO on your system, type the following in the MICO top level directory:

nmake /f Makefile.win32

If you are running Windows 95/98, the command line shell suffers from some serious deficiencies. On those platforms you need to invoke the compilation process using the following command instead:

nmake /f Makefile.win32 w95-all

The make process will build all the necessary DLLs and executables in a subdirectory called win32-bin, which will be created during compilation. The content of this directory is the only thing you need for building MICO applications. You can move it to your preferred location. The build will require around 150MB (the demo directory another 90MB).

You should modify the PATH environment variable to include this directory. If, for example, the MICO sources were unzipped in C:\mico, then type the following:

PATH C:\mico\win32-bin;%PATH%

Writing MICO applications using the IDE

All the examples that come with MICO depend on Makefiles for the building process. The advantage of a tool like Visual-C++ is that it offers an Integrated Development Environment (IDE), which combines editor, compiler and debugger in one tool. The IDE also manages all the files which belong to a project. This section gives you an indication on how to use the IDE together with MICO. First you have to tell Visual-C++, where MICO is located. You do this in the Tools/Options dialog, in the Directories tab, you have to set the Include path to the following directories:

C:\mico\win32-bin\include\windows

C:\mico\win32-bin\include

These lines have to be first in the list (use the move buttons to move them to the first position). Next, set the Library path to (order does not matter):

C:\mico\win32-bin\lib

and the Executables path accordingly to:

C:\mico\win32-bin

In the project settings you have to make the following changes:

Compiler:
You have to define _WINDOWS in the Preprocessor options. In the Code Generation options you have to use the Multi-Threaded DLL version of the runtime library, because that is the way MICO was compiled.

Linker:
You have to add micoXXX.lib and wsock32.lib (where XXX is the three digit version number of MICO without the dots) to the Object/Library modules input field (Hint: Before you do this select All configurations in the upper left combo box named Settings for) Additionally, you can integrate your IDL files in the build process. First you have to add the IDL file to your project, then goto Project/Settings and select this file, or right click on the IDL file and choose Settings, select the Custom Build tab and enter:

idl --c++-suffix=cpp [other options] $(InputPath)

into the Build Command listbox. In the Output files list box enter:

$(InputName).h
$(InputName).cpp

For inserting $(..) you can also use the popup buttons at the bottom of the dialog, or you can use the real filename instead. The output files of the IDL compiler are created in the current directory; normally the root of the project. If the output filename is foo.cpp, then you have to add foo.cpp to the project. This can be done even before the file exists, by entering it into the file dialog.

--------------------------------------------------------------------------------

分段
预备知识
编译MICO源代码
在集成环境下编写MICO应用

--------------------------------------------------------------------------------

用Visual-C++安装MICO
在WINDOWS下安装MICO,并使用Visual-C++编译器是十分不同的工作.提请注意的是这个编译在技术上来说不是很可靠的一种,所以你得装好所有的服务包.(微软的说法是BUG修订).另一种可取的做法是查看有没有WINDOWS平台下最新发布的MICO,内容包含在文件README-WIN32中.

预备知识
编译WINDOWS下的MICO你需要Visual-C++ 5.0的服务包 3 或(首选) Visual-C++ 6.0 服务包2.注意没有Visual-C++服务包3 你不能编译源码或编写MICO应用。WINDOWS版本的flex和bison不是必需的.MICO发布已经包含有这些工具产生的文件. VC++ 5.0 SP3在下述地方提供:

http://www.microsoft.com/msdownload/vs97sp/full.asp

VC++ 6.0 服务包提供在:

http://msdn.microsoft.com/vstudio/sp/default.asp

Windows
95的TCP/IP协议栈实现会导致MICO应用出问题,你得下载并安装WINSOCK2库来修正这些问题.你可以免费的从微软WEB服务器上下载WINSOCK2:

http://www.microsoft.com/windows95/downloads/contents/wuadmintools/\
s_wunetworkingtools/w95sockets2/default.asp?site=95

注意: 为了使用Visual-C++你得确认环境变量已经完全设定好了.为了这个目的有一个特定批处理文件叫做VCVARS32.bat . 在你试图编译MICO前必须确认运行这个批文件--做为VC++的组成部分.

一旦你确实将上述的准备工作都做完了,你就可以解包MICO源代码.源代码包在CD盘上打成zip格式文件。

mico-<版本>.zip

<版本> 是包含在CD上的MICO发布的版本号. 在想放置的地方解压这个包.

编译MICO源码
进入你已经解压好的MICO源码的目录并编辑文件MakeVars.win32.设置SRCDIR变量为MICO所在位置的目录(不要跟反斜线符号).不需要运行设置脚本,MICO已经为WINDOWS做好了预设定.

VC++本身所带的Makefile工具叫做nmake.不幸的是这个工具和其它make工具不是十分兼容。因为这个原因,MICO发布包含有第二个Makefiles文件集.这些Makefiles文件有扩展名.win32并已经为了在nmake下工作做了必要的修订.在你的系统里编译MICO,在MICO顶级的目录下输入以下命令:

nmake /f Makefile.win32

如果你在跑Windows 95/98,命令行还有一些严重不足之处。在那些平台上调用编译过程你得修正为以下命令行:

nmake /f Makefile.win32 w95-all

整个make过程将会在win32-bin子目录下构建所需动态链接文件和可执行文件,那些文件将会在整个编译过程中创建。整个目录的内容就是做构建MICO应用这件事情.你可以将它移到你心目中首选的位置去.构建将要大约150M(演示目录要另外90M)空间.

你应该修正路径环境变理来包括这个目录.如果举例,MICO源码解压到C:\mico,输入以下命令:

PATH C:\mico\win32-bin;%PATH%

在集成环境下开发MICO应用
所有的随MICO而来的必需的Makefiles文件都用于构建过程.象Visual-C++这样的工具的好处是提供了一个集成开发环境(IDE),一个工具里面包含了编辑器,编译器和调试器.IDE也管理所有属于项目的所有文件.该章节给出你在MICO装入后如何在IDE中使用MICO的指南.在工具/选项对话框中,选择目录标签,你可以设定以下包含路径:

C:\mico\win32-bin\include\windows
C:\mico\win32-bin\include
这些行得放置在列表的第一项(用移动按钮移动他们到第一个位置).下一步,设置库路径(顺序不是太要紧):
C:\mico\win32-bin\lib

并因此设定可执行文件的路径:

C:\mico\win32-bin

在项目设定中你还得做以下改变:

编译器:
你得在预处理的选项中定义 _WINDOWS.在代码生成选项中得用多线程版本的运行库,因为这些都MICO编译时所需的。
链接器:
你得加入micoXXX.lib和wscok32.lib(XXX是MICO不带点的3位数字的版本号)到目标/库模块输入域(提示:你做这项选择时所有的设定都得出现 在叫做设定为的最上方左边的组合框中.)
接着,你要整合你的IDL文件进构建过程中.首先你加入IDL文件到你的项目,然后在项目/设置中选择这个文件,或者在IDL文件上右击选择设定,选择自定义构建标签并输入:

idl --c++-suffix=cpp [other options] $(InputPath)

在构建命令行列表框里. 在输出文件列表框里输入:

$(InputName).h
$(InputName).cpp

在插入中$(..)你可以使用底部对话框的弹出按钮,或使用真实文件名代替.IDL编译器创建的输出文件将放在当前目录下;通常都是项目的根目录.如果输入文件名是foo.cpp,那你得加foo.cpp到项目中. 这在文件存在前能很好工作,通过把它输入进文件对话框中.