Websocket ++ compilation process and websocket compilation process

Source: Internet
Author: User
Tags openssl library openssl version

Websocket ++ compilation process and websocket compilation process

Websocket ++ is an open-source websocket library that can be used to develop websocket-based services.
Some time ago, we successfully compiled websocket ++. The process of compiling websocket ++ is as follows:
1. Install Python. In this example, install Python27.
2. Install scons. This program is responsible for building a cross-platform coding script. Python support is required.
3. Configure Python, scons, and environment variables:
C: \ Python27 // Python27 environment variable
C: \ Python27 \ Scripts // scons environment variable

4. Compile openssl // boost Dependencies
5. Compile boost // use the boost library in websocket
6. Compile websocket ++

The compiling process is openssl-> boost-> websocket, and a 32-bit Running Environment Program is generated.

The openssl version: openssl-1.0.2a, boost: boost_rj51_0, websocket ++ (0.3.0-alpha4)


Openssl compilation requires perl support. After perl is installed, environment variables are configured. In this example, C: \ Perl64 \ bin.
In the openssl root directory INSTALL. W32, we introduced the coding process:
1. Open the vs2010 tool cmd x86 environment // vcvarsall x86
2. cd H: \ openssl-1.0.2a \ openssl-1.0.2a
3. perl Configure VC-WIN32 no-asm // no assembly environment is installed, so add no-asm otherwise an error is reported
4. ms \ do_ms
5. nmake-f ms \ ntdll. mak

Boost Coding Process
1. Decompress boost_000051_0, open the vs2010 tool cmd x86 environment, and switch to the decompressed directory.
2. Run bootstrap. bat to generate bjam
3. cmd environment, enter bjam install architecture = x86 address-model = 32 -- toolset = msvc-10.0 -- without-python -- build-type = complete -- prefix = "H: \ boost_1_51_0 \ boost_1_51_0 \ bin \ vc10_prefix_dll_arcx86_addr32 "link = static runtime-link = shared threading = multi debug release
4. Configure environment variables:
Boost_shortdes = H: \ boost_1_51_0 \ boost_1_51_0 \ bin \ vc10_prefix_dll_arcx86_addr32 \ include \ boost-1_51
BOOST_LIBS = H: \ boost_1_51_0 \ boost_1_51_0 \ bin \ vc10_prefix_dll_arcx86_addr32 \ lib

Because websocket ++ uses the boost library, this routine incorporates the openssl include lib into the boost library path.
1. Copy openssl-1.0.2a \ openssl-1.0.2a \ include \ openssl to boost_1_51_0 \ boost_1_51_0 \ bin \ vc10_prefix_dll_arcx86_addr32 \ include \ boost-1_51
2. Copy the openssl compiler input result: copy the out32dll directory (libeay32.lib, ssleay32.lib) to H: \ boost_5151_0 \ boost_51_0 \ bin \ vc10_prefix_dll_arcx86_addr32 \ lib

Websocket ++ routine coding process (0.3.0-alpha4)
1. Decompress websocket ++, open cmd, and switch to the decompressed directory.
2. Modify the SConstruct file because I am a Windows 7 64-bit System and the default compilation result is 64-bit. In this example, to compile the x86 environment, modify the SConstruct file:
A. for example, change env ['linkflags'] = '/INCREMENTAL: NO/MANIFEST/NOLOGO/OPT: REF/OPT: ICF/MACHINE: X64': env ['linkflags'] = '/INCREMENTAL: NO/MANIFEST/NOLOGO/OPT: REF/OPT: ICF/MACHINE: X86'
B. Change env = Environment (ENV = OS. environ) to env = Environment (ENV = OS. environ, TARGET_ARCH = 'x86 ') at the beginning of the line ')


A sets the target program running environment to x86 machines. B TARGET_ARCH = 'x86 'sets the compiling environment to x86. If 64-bit is compiled, change it to/MACHINE: X64 TARGET_ARCH = 'amd64'

3. Modify examples/utility_client/utility_client.cpp, which references the chrono library. The Library is the cpp11 standard library, which is not supported by vs2010. Remove the code that contains the chrono reference section.
4. Add a reference to the openssl section in utility_client.cpp:
# Pragma comment (lib, "libeay32.lib ")
# Pragma comment (lib, "ssleay32.lib ")


Previously, we copied the openssl compilation result to the boost lib library. Therefore, we can directly reference it here.
You do not need to copy the openssl library to the boost directory. Put the openssl library into the C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC directory lib and include directory, the effect is the same.


Now, all preparations are complete. In the cmd environment, extract the 0.3.0-alpha4 directory, run scons, and finally show scons: done building targets. It indicates that the websocket ++ routine has been compiled successfully.










Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.