Install and use stlport in vs2010

Source: Internet
Author: User
Tags visual studio 2010

Install and use stlport in vs2010

1. Local Environment

Win7 64-bit

Visual Studio 2010 flagship Edition

STLport-5.2.1.tar.bz2

2. Download stlport

Http://sourceforge.net/projects/stlport/

Download and decompress the package. The decompress path is D: \ stlport. decompress the package to include multiple files and directories.

3. modify configuration

(1) Add the following directory to the path environment variable of the system: (this directory is the location where vs2010 is installed)

D: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc \ bin (my machine only)

(2) edit the vcvars32.bat File

Full directory of this file: D: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc \ bin \ vcvars32.bat

Add the include (header file) path and Lib (library file) path of stlport to this file, so that vs can find the files we include, such as: # include <string>.

The modified content is as follows:

@ REM include
@ REM -------
@ If exist "% vcinstalldir % atlmfc \ include" set include = % vcinstalldir % atlmfc \ include; % include %; D: \ stlport
@ If exist "% vcinstalldir % include" set include = % vcinstalldir % include; % include %

@ REM lib
@ REM ---
@ If exist "% vcinstalldir % atlmfc \ Lib" set Lib = % vcinstalldir % atlmfc \ Lib; % lib %; D: \ stlport \ build \ Lib
@ If exist "% vcinstalldir % lib" set Lib = % vcinstalldir % LIB; % lib %

After saving the file, double-click to execute the file (vcvars32.bat). After the execution is successful, the following message is displayed:

D: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc> vcvarsall. bat
Setting environment for using Microsoft Visual Studio 2010x86 tools.

(3) EDIT _ cstdlib. h

The file is located at the decompression path D: \ stlport \ STL.

The following shows the contents of the 158th rows in the file:

Inline _ stlp_long_long ABS (_ stlp_long_long _ x) {return _ x <0? -_ X: _ x ;}

Add a condition judgment statement before and after the change bit. The modified content is as follows:

# If! Defined (_ stlp_msvc) | (_ stlp_msvc <1600)
Inline _ stlp_long_long ABS (_ stlp_long_long _ x) {return _ x <0? -_ X: _ x ;}
# Endif

(4) Compile stlport

In the "Start" menu, select the "Visual Studio command prompt (2010)" tool in the "Visual Studio Tools" folder under "Microsoft Visual Studio 2010;
Then switch the command line path to: D: \ stlport;

Execute the command: Configure msvc9

Switch to: D: \ stlport \ bulid \ Lib

Run nmake/F msvc. Mak clean install

4. Configuration and Test

(1) Add three dynamic libraries in the D: \ stlport \ binfile:

Stlport.5.2.dll

Stlportd.5.2.dll

Stlportstld.5.2.dll

Copy to the following path:

D: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc \ bin \

(2) include the include (header file) and Lib (library file) of stlport in the configuration of vs 2010. The best way is to perform permanent configuration, so that you can use these configurations for each new project, instead of adding these configurations to each project. The method is as follows:

In vs2010, choose "View"> "Property Manager"> "Debug | Win32"> "Microsoft. CPP. win32.user, add the "D: \ stlport" path to the "include directory" on the "General" tab, and add "D:" to the "library directory: \ stlport \ Lib "path.

When using stlport, you can use different macros to decide whether to use dynamic or static link STL.

# DEFINE _ stlp_use_boost_support // use stlport with boost Library

# DEFINE _ stlp_use_static_lib // static link stlport

# DEFINE _ stlp_use_dynamic_lib // dynamic link stlport

# DEFINE _ stlp_debug // debug mode

(3) create a C ++ project for testing. The test code is as follows:

Because stlport has added some useful extensions outside of the standard, such as rope (enhanced string class), we use crope to test whether our stlport is successfully installed.

# Include <iostream>

# Include <rope>

Int main (INT argc, char * argv [])

{

STD: crope myrope ("Hello world! ");

STD: cout <myrope <STD: Endl;

System ("pause ");

Return 0;

}

If the output is true, the configuration is successfully installed.

Install and use stlport in vs2010

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.