The construction of Aces (vc++6.0 Environment)
Building an ACE under Windows
1. Unzip the ace-5.5.zip to the desired installation directory, where e:/is used as an example, and the Ace_wrappers folder is extracted, so the ACE will be present in the Ace_wrappers/ace directory. Ace_root=e:/ace_wrappers.
2. Create a new ace_root environment variable in the system and set the value to E:/ace_wrappers. Set to: My Computer, properties, advanced environment variables--NEW
3. Create a header file in the E:/ace_wrappers/ace directory named Config.h with the following contents:
#include "ace/config-win32.h" (Required option)
#define ACE_HAS_STANDARD_CPP_LIBRARY 1 (MSVC standard C + + header file)
#define ACE_HAS_MFC 1 (used with MFC)
#define Ace_no_inline (canceling the function inline to reduce the size of the static library and the run code)
#define ACE_AS_STATIC_LIBS (static version of Build Aces)
#define ACE_HAS_WINNT4 0 (required to build on Windows 9x/me, remove some winnt/win2k-specific code in the ACE)
All you need to do is add the first two items.
4. In VC + + load ACE project file (ACE_ROOT/ACE/ACE.DSW), in release and debug two compile mode to compile, get 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 the debug version. How to do: Run VC + +, choose Build->batch build ..., ace-win32 Debug and Ace-win32 release are all selected, Rebuild all. As shown in the following:
According to the above method may only compile the ACE.dll, ACE.lib library files, the specific reason is unknown. You can build all of the library files successfully by following the procedure below. How to: Build->set Active Configuration ... Select Ace-win32 release separately to compile. As shown
Also open ACE_STATIC.DSW compile build ACEs.lib, ACEsd.lib, Ace_rmcasts.lib, Ace_rmcastsd.lib, TMCasts.lib, TMCastsd.lib
5. Configure the ACE environment. Open vc++6.0, select Tools->options->directories to add the following:
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 you write a program, you set the following settings in the Project->settings menu:
A/C + + TAB:
Code Generation: Select the multithreaded version of the runtime Library (multithreaded DLL).
Preprocessor: Add $ace_root to the Additional Include Directories field.
Link tab:
Input: Include the appropriate ACE library file in the "Object/library modules" field, in the "Additional Library
Path field contains the paths to the ACE Library link files. This is usually ace_root/ace.
Where 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
The main use of the above two libraries.
6. Add E:/ace_wrappers/bin to the variable path in the system environment, or you will run into a problem that looks for Ace.dll or Aced.dll when running the program.
7. When used in an MFC program, it should be added in InitInstance ():
Wsdata Wsdata;
WORD verrequested = Makeword (2, 2);
Wsastarup (verrequested, &wsdata)
Note: You can add the following code to the header file without manually adding Lib library files
#ifdef _DEBUG
#pragma comment (lib, "Aced.lib")
#else
#pragma comment (lib, "Ace.lib")
#endif
8. There may be an error when you release Windows, with the following errors:
Error C2039: ' tryentercriticalsection ': is not a member of ' Global
Error C2065: ' tryentercriticalsection ': undeclared identifier
Workaround:
Project Project-->setting-->c/c++ write: _win32_winnt=0x0500
The construction of Aces under Linux
1. Set the environment variable ace_root with the following command:
"Vi/etc/profile", add 4 lines after "Export PATH USER ...."
? Ace_root=/opt/ace
? Export Ace_root
? Ld_library_path= $ACE _root/aceld_library_path
? Export Ld_library_path
Once completed, the/etc/profile is executed once, command: "chmod 555/etc/profile", "/etc/profile". So our ace_root is set up, you can use the following command to see if Ace_root is set: "Echo $ACE _root", this time it is best to reboot boot Linux.
2. Unpack the ACE.tar.gz package:
Do not own the ACE.tar.gz package completely untied, special emphasis not to completely untie, the following can see the installation script will give us to untie it; If you manually untie all, the installation script will delete your unzipped directory! All we have to do is just separate the ace-install.sh installation script from the ACE.TAR.GZ package and modify it. We just need this one file to do it. Use mkdir to build the directory, such as/home/my/ace, and then place your ACE.tar.gz in this directory (with the CP command copy or the MV command to move to this directory). Note that this directory will be your ACE.tar.gz directory, the installation script will come to this directory to find this file, this directory and Ace_root is not the same, and ace-install.sh also prompted not to set the two directories to the same directory. Ace_root will be our target directory for installation.
3. Extract the individual file ace-install.sh from the ACE.tar.gz command as follows:
"Tar–zxvf ace+tao+ciao.tar.gz ace_wrappers/ace-install.sh"
After the solution, a new subdirectory "Ace_wrappers" will come out. You can now move the ace-install.sh to the outside directory: "mv/ace_wrappers/ace-install.sh." “.” Represents the current directory. Of course ace-install.sh in what path is not affected, because we want to change the content of ace-install.sh, there are many paths to be modified. Now in the/home/my/ace have ace-install.sh, we now use VI to modify it, before you can back up the first one. 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 ", is changed to our own built, put the ACE.tar.gz file directory, and then remove the previous comment" # "number. Next, find "my_ace_config=config-sunos5.4-sunc++-4.x.h" and change it to "my_ace_config=config-linux.h", which is the configuration file under Linux. Continue to change, find "my_ace_gnu_macros=platform_sunos5_sunc++." GNU ", change it to" my_ace_gnu_macros=platform_linux. GNU ". This is the GNU macro file setting under various operating system platforms. After the file has been modified, save exit ": Wq".
4. Install the ACE:
This should be in the/home/my/ace directory, we do: h./ace-install.sh
Thereafter, it will be a long time to unpack, compile, and wait. This process will not cause any errors, because the installation script will do many things for us, such as: Generate Config.h, generate Platform_macros. Gnu. We do not need to press ace-install.html said manual change things: Do not have to do the connection "Ln-s config-sunos5-sunc++-4.x.h config.h", the installation script will give us a good; (digression: There is no file connection in Windows.) , so you want to generate a config.h file yourself, and then add a word in it "#include" ace/config-win32.h "". )
If an error occurs in the compilation, such as ".. /apps/gperf "And so on, please edit the $ace_root/apps under the makefile, the part of the" gperf "comment out, this thing is just an example, you can not compile it.
Emphasize that using ace-install.sh to install, will compile ace, tests, apps and so on. Finally, libace.so and tests will be generated and many compiled files will come out under apps.
Of course if you just download a single package such as ACE.tar.gz to install, you can manually change the file, then make, because only compile ace, the work is much less, hand-done can also be accepted.
Ace Learning Materials
1. Ace Programmer's Guide: Practical Design patterns for network and system programming the practical design pattern of network and system programming ACE Programmer ' s guides practical design Patterns for network and systems Prog Ramming
Beauty Stephen D. Huston, James CE Johnson, (US) Umar Syyid
Minchinmavida China Electric Power Press
2. C + + Network programming Volume 1: Using Aces and patterns to eliminate complexity
C + + Network programming Volume 1 mastering complexity with aces and Patterns
Beauty Douglas c.schmidt,stephen D.huston/[Mei]douglas c.schmidt,stephen D.huston, in the spring translation Huazhong University of Science and Technology press
3. C + + network programming, Volume 2 based on the systematic reuse of aces and frameworks
C + + network programming, Volume 2 systematic reuse with ACE and frameworks
Douglas C.schmidt, Stephn D.huston/| Minchinmavida Translation Industry Publishing house
4. ACE's official website http://www.cs.wustl.edu/~schmidt/ACE.html
5. Minchinmavida's homepage http://www.flyingdonkey.com/
6. Riverace company Http://www.riverace.com
7. Grey 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"
Workaround:
Project->settings->c/c++: Add $ace_root to Preprocessor's additional include directories, such as E:/ace_wrappers
Error 2:
"You must link against multi-threaded libraries when using ACE (check your project settings)"
Workaround:
Project->settings->c/c++: Code Generation use run-time library:debug multithreaded Dll
Error 3:
"Error C2065:ACE_ERROR:undeclared Identifier"
"Error C2065:ACE_DEBUG:undeclared Identifier"
Workaround:
Add # include ace/log_msg.h to the original horse
Error 4: "Error C4716:ace_main_i:must return a value"
Workaround:
Add return 0 to main;
Error 5:
"Error lnk2001:unresolved external symbol __declspec (dllimport) int __cdecl"
Workaround:
Project->settings->link->input:object/library modules joins Aced.lib, Additional library path joins $ace_root/ace, such as E:/ace_wrappers/ace
Issues encountered in compiling the client:
Error 6:
Error C2039:sprintf:is not a member of Ace_os
Workaround: #include ace/os_ns_stdio.h
Error 7:error C2039:strlen:is not a member of Ace_os
Workaround: #include ace/os_ns_string.h
Error 8: Unable to find the dynamic link library Aced.dll to the specified path
Workaround: Add D:/ace_wrappers/bin to the system variable path
Static contains:
Engineering-Set-c/c++-preprocessor definition to add, ace_as_static_libs
Example 1server build after compilation
Server.exe 16K serverd.exe 97K servers.exe 124K serversd.exe 669K
(Servers.exe is more suitable for publishing)
Example 2 client compiled post-build
Client.exe 16K clientd.exe 97K clients.exe 124K clientsd.exe 669K
(Clients.exe is more suitable for publishing)
Test Clients 127.0.0.1 1919
Servers 1919
If the compiler supports 64-bit, what is the macro definition to differentiate between 64-bit or 32-bit?
Answer: #define VER ((2>>31) >0?64:32)------------------------------------------------------- to Ace Junior's first sister.
To Ace Junior's first sister.
Version 0.1.0 Stone JIang 2006-11-6
The following is a list of beginner Ace Essential basic knowledge, hoping to give beginners ace friends a little help. Special plus version number, which is to welcome criticism, additions and revisions.
1. C++/oop (a part of the master is the C language background deep-rooted, thinking is not object-oriented, this kind of human ace needs to fill the OOP idea first)
2. Design pattern (ACE is not just a class library, but a series of related classes that work together through patterns, and if you are familiar with the design pattern, it will help you learn ACE)
3. The framework (the framework should not be formal, similar words can also be architecture, no matter what the words, to point out that ACE is not only a class library, but also through the pattern of a combination of mutually cooperative classes formed by the semi-finished. Frameworks are different from class libraries, which are usually passive code calls written by programmers, while frameworks tend to invoke user-implemented interfaces, known as Hollywood principles--don ' t call me
4.Linux (I am a Linux novice, but since I began to enter the Linux programming, I found that ace many of the essence from Linux, before the ace Understanding is limited, do not know why, in fact, in Linux can find the answer, ACE flashing Linux wisdom. )
5. Richard Stevens. (Richard, who died young, should be Douglas's mentor, his writings affect the Douglas, but also the ACE, here is the TCP/IP illustrated, in fact, Richard other works, such as Apue are all big aids)
6. No 6. If you think so, be sure to tell me. http://blog.csdn.net/adcxf/article/details/2321005
The construction of Aces (vc++6.0 Environment)