Ace construction (VC ++ 6.0 environment)
Ace construction in Windows
1.Extract ace-5.5.zip to the required installation directory. Here, E: \ is used as an example to decompress the package and form the ace_wrappers folder. Therefore, Ace will exist in the ace_wrappers \ ACE directory. Ace_root = E: \ ace_wrappers.
2.Create an ace_root environment variable in the system and set it to E: \ ace_wrappers. Specific settings: My computer> Properties> advanced> environment variables> New
3.In the E: \ ace_wrappers \ ACE directory, create a head file named config. h with the following content:
# Include "ACE/config-win32.h" (mandatory)
# Define ace_has_standard_cpp_library 1 (Standard C ++ header file included in msvc)
# Define ace_has_mfc 1 (used with MFC)
# Define ace_no_inline (cancel function inline to reduce the size of the static library and runtime code)
# Define ace_as_static_libs (build static ace Version)
# Define ace_has_winnt4 0 (required for building on Windows 9x/Me, remove some special winnt/Win2k codes in ACE)
You only need to add the first two items.
4.Load the ACE project file (ace_root \ ACE. DSW), compile in the release and debug modes to obtain the corresponding library file (Ace. DLL, Ace. lib and aced. DLL, aced. lib), where ace. DLL, Ace. lib is generated by the release version, aced. DLL, aced. lib is generated by debug. Specific Operation Method: run VC ++, select build-> batch build ..., Select both ACE-Win32 debug and ACE-Win32 release, and rebuild all. As shown in:
The above method may only compile the ace. dll and Ace. Lib library files. The specific reason is unknown. Compile as follows to generate all the library files. Specific Operation Method: Build-> set Active configuration... Select the ACE-Win32 release for compilation. As shown in
Also open ace_static.dsw to compile and generate aces. Lib, acesd. Lib, ace_rmcasts.lib, ace_rmcastsd.lib, tmcasts. Lib, and tmcastsd. Lib.
5.Configure the ace environment. Open VC ++ 6.0 and choose tools> Options> directories to add the following content:
1) Executable File: e: \ ace_wrappers \ bin
2) include file: e: \ ace_wrappers
3) library files: e: \ ace_wrappers \ Lib
4) source files: e: \ ace_wrappers
When writing a program, you must set the following settings in the project> Settings menu:
C/C ++ tab:
Code Generation: select the multi-threaded Runtime Library (multithreaded DLL ).
Preprocessor: add $ ace_root to the "Additional include directories" domain.
Link tab:
Input: contains the appropriate ace library file in the "Object/library modules" field.
Path "contains the path of the ACE Library Link file. This is usually ace_root/ace.
The DLL debug corresponds to aced. Lib.
DLL release corresponds to ace. Lib
Static library debug corresponds to acesd. Lib
Static library release corresponds to aces. Lib
Mfc dll debug corresponds to acemfcd. Lib
Mfc dll release corresponds to acemfc. Lib
These two databases are mainly used.
6.Add E: \ ace_wrappers \ bin to the PATH variable in the system environment. Otherwise, you may encounter the issue of searching for Ace. dll or aced. dll when running the program.
7.When using it in the MFC program, you should add the following in initinstance:
Wsdata;
Word verrequested = makeword (2, 2 );
Wsastarup (verrequested, & wsdata)
Note: You can add the following code to the header file without manually adding the Lib library file.
# Ifdef _ debug
# Pragma comment (Lib, "aced. lib ")
# Else
# Pragma comment (Lib, "Ace. lib ")
# Endif
8.An error may occur when release is running in Windows. The error is as follows:
Error c2039: 'tryentercriticalsection ': is not a member of ''global
Error c2065: 'tryentercriticalsection ': Undeclared identifier
Solution:
Project --> setting --> C/C ++ write: _ win32_winnt = 0x0500
Ace construction in Linux
1.Set the environment variable ace_root. The command is as follows:
"VI/etc/profile", in "Export path user ...." Add four rows later
Ace_root =/opt/ace
Export ace_root
LD_LIBRARY_PATH = $ ace_root/aceld_library_path
Export LD_LIBRARY_PATH
Run/etc/profile once. Run the command "chmod 555/etc/profile" and "/etc/profile ". In this way, we have set ace_root. You can run the following command to check whether ace_root is set: "Echo $ ace_root". At this time, we 'd better restart Linux by reboot.
2.Decompress ace.tar.gz package:
Do not manually unbind the ace.tar.gz package. Especially, do not unlock it completely. You can see that the installation script will unlock it for us, the installation script will delete your unzipped directory! The only thing we want to do is to separate the ACE-install.sh installation script in the ace.tar.gz package and modify it. We only need this file. Use mkdir to create a directory, such as/home/My/ace. then, put your ace.tar.gz in this directory (use the CP command to copy or move the MV command to this directory ). Note that this directory will be your directory storing ace.tar.gz. The installation script will come to this directory to find this file. This directory is different from ace_root, and Ace-install. sh also prompts you not to set these two directories to the same directory. Ace_root will be our installation target directory.
3.Extract A single file ACE-install.sh from ace.tar.gz with the following command:
"Tar-zxvf ace?tao=ciao.tar.gz ace_wrappers/ACE-install.sh"
After the solution is completed, a new sub-directory named "ace_wrappers" will be generated ". At this point you can first move the ACE-install.sh to the external Directory: "mV/ace_wrappers/ACE-install.sh." "." represents the current directory. Of course, ACE-install.sh in what path is no impact, because we want to modify the content of the ACE-install.sh, there are a lot of paths to modify. Now in/home/My/ace there is a ACE-install.sh, we now use VI to modify it, you can back up a first before modification. Command: CP ACE-install.sh ACE-install.sh.bak, VI ACE-install.sh first find my_acedir =$ {home}/aceconfig ", change it to "my_acedir =/home/My/ace”, and then change it to the directory where the ace.tar.gz file is saved in our tutorial. Then, remove the comment. Next, find "my_ace_config = config-sunos5.4-sunc ++-4. x. h, change it to "my_ace_config = config-Linux. h, that is, to change to the configuration file in Linux. Change "my_ace_gnu_macros = platform_sunos5_sunc ++. GNU" to "my_ace_gnu_macros = platform_linux.gnu ". This is the GNU macro file settings for various operating system platforms. After the file is modified, save and exit ": WQ ".
4.Install ACE:
At this point it should be in the/home/My/ace directory, we execute: H./ACE-install.sh
This will take a long time to unpack and compile. There will be no errors in this process, because the installation script will do a lot for us, such as generating config. h and generating platform_macros.gnu. We do not press the ace-install.html to say that the manual change: do not do the connection "ln-s config-sunos5-sunc ++-4. x. h config. H ", the installation script will be ready for us; (Subject: There is no file connection in windows, so you need to generate a config. h file, and then add a sentence "# include" ACE/config-win32.h "" in it "".)
If an error occurs during compilation, such as ".. /apps/gperf. Edit the makefile under $ ace_root/apps and comment out the "gperf" section. This is just an example. You can skip compiling it.
To emphasize that the installation with ACE-install.sh will compile ace, tests, apps and so on. Finally, libace. So, tests, and apps are generated, and many compiled files are generated.
Of course, if you only download a single package such as ace.tar.gz for installation, You can manually modify the file and make it again. Because only ace compilation is required, much less work will be done, and it is acceptable to do it manually.
Ace learning materials
1. Ace programmer's Guide: Practical Design Patterns for network and system programming practical design patterns for network and system programming ace programmer's guide practical design patterns for network and systems programming
(US) Stephen D. Huston, (US) James ce Johnson, (US) Umar syyid
Mavida translation China Power Press
2. c ++ network programming Volume 1: Using ace and mode to eliminate complexity
C ++ network programming volume 1 mastering complexity with Ace and patterns
[Us] Douglas C. Schmidt, Stephen D. Huston/by [us] Douglas C. Schmidt, Stephen D. Huston, translated by chunjing to Huazhong University of Science and Technology Press
3. c ++ network programming, Volume 2 systematic reuse based on ACE and framework
C ++ network programming, Volume 2 systematic reuse with Ace and frameworks
Douglas C. Schmidt, Stephen n d. Huston/by | mavida translation Electronics Industry Press
4. Ace http://www.cs.wustl.edu /~ Schmidt/ace.html
5. mavida home page http://www.flyingdonkey.com/
6. riverace http://www.riverace.com/
7. gray fox http://www.huihoo.com/
8. Ace class library http://dev.csdn.net/article/40/40700.shtm.
Common Errors
Error 1:
"Cannot open include file: ACE/sock_acceptor.h: no such file or directory"
Solution:
Project-> Settings-> C/C ++: Preprocessor additional include directories to add "$ (ace_root)", such as E:/ace_wrappers
Supplement: In vs2005, click project> Properties> C/C ++> General> Add "$ (ace_root)" to the additional include directory )".
Error 2:
"You must link against multi-threaded libraries when using ACE (check your project settings )"
Solution:
Project-> Settings-> C/C ++: Use run-time library of code generation: Debug multithreaded DLL
Error 3:
"Error c2065: ace_error: Undeclared identifier"
"Error c2065: ace_debug: Undeclared identifier"
Solution:
Add # include ACE/log_msg.h to the original horse
Error 4: "error c4716: ace_main_ I: must return a value"
Solution:
Add return 0 to main;
Error 5:
"Error lnk2001: unresolved external symbol _ declspec (dllimport) int _ cdecl"
Solution:
Project-> Settings-> link-> input: Object/library modules is added to aced. Lib, and $ ace_root \ ACE is added to additional library path, such as E: \ ace_wrappers \ ACE.
Supplement: In vs2005, choose Project> Properties> linker> General> additional library directory to add "$ (ace_root) \ Lib ".
Problems encountered during client Compilation:
Error 6:
Error c2039: sprintf: is not a member of ace_ OS
Solution: # include ACE/OS _ns_stdio.h
Error 7: Error c2039: strlen: is not a member of ace_ OS
Solution: # include ACE/OS _ns_string.h
Error 8: The specified path of the dynamic link library aced. dll cannot be found.
Solution: Add D: \ ace_wrappers \ bin to the path of the system variable.
Static include:
Project-set-C/C ++-add to the pre-processing program definition, ace_as_static_libs
Example 1 server is generated after compilation
Server.exe 16 K serverd.exe 97 K servers.exe 124 K serversd.exe 669 K
(Servers.exe is suitable for publishing)
Example 2 generated after the client is compiled
Client.exe 16 K clientd.exe 97 K clients.exe 124 K clientsd.exe 669 K
(Clients.exe is suitable for publishing)
Test clients 127.0.0.1 1919
Server 1919
If the compiler supports 64-bit, what macro definition is used to distinguish between 64-bit and 32-bit?
A: # define Ver (2> 31)> 0? 64: 32 )-------------------------------------------------------What should I say to Ace's first brother and girl?
Version 0.1.0 Stone Jiang 2006-11-6
The following lists the basic knowledge necessary for beginners to learn about ACE, hoping to help those beginners. The version number is added to welcome criticism, supplement, and revision.
1. c ++/OOP)
2. Design Pattern (Ace is not just a class library, but a series of related classes that work together through patterns. If you are familiar with design patterns, it will help you learn Ace)
3. framework (the framework should not be formal. Similar words can also be architecture. No matter what words are used, it should be pointed out that Ace is not just a class library, it is also a semi-finished product formed by combining modes in a collaborative class. The framework is different from the class library. The latter is usually passively called by code written by programmers, while the framework often actively calls user-Implemented interfaces, well-known Hollywood principles-Don't call me, I will call you)
4. linux (I was a beginner in Linux, but since I started programming in Linux, I found that many of the essence of ACE comes from Linux. I used to have limited understanding of ACE and I don't know why, in fact, we can find the answer in Linux. Ace is filled with the wisdom of Linux .)
5. richard Steven S. (Richard, who died early in the year, should be a mentor of Douglas. His work affects Douglas and Ace. Here we will talk about TCP/IP protocol strated. In fact, Richard's other books, like apue)
6. No more than 6. If you think so, please tell me.
From: http://blog.programfan.com/article.asp? Id = 29491