STLport-5.2.1 STL port configuration, cl.exe compiled Cpp:ms and Cygwin two modes, Cygwin environment configuration and usage, GCC compilation primer

Source: Internet
Author: User
Tags vc9

1, in MS to use the Windows SDK and related Lib settings is too troublesome, as well as the DLL and other files missing is in serious. So I simply took advantage of the batch file in the VS installation directory and entered in the command window:

C:\Program Files (x86) \microsoft Visual Studio 11.0\VC, directly running Vcvarsall.bat load VS and configured environments, you can use the command line: CL-GX Hello.cpp to implement compile and run. Version 2012 vs in-gx replaced with-EHSC. Similarly I can use vs2013. At present vs2013 environment I mainly used to test the grammar of c++11, I will switch the environment if it does not pass or is not expected to result in the situation.

If I get the quickest solution, this blog is over?

Imitation as human standing on the shoulders of giants such magical skills, I am of course not to be outdone.

Since the environment configuration of VS is correct, pull it out:


Current Runtime DLL library (to be continued). ), the same path should be used with path. Note: You can access one of my other blogs about the path of VS.

The path to be ignored requires the use of CL parameters to compile, is still a side dish, will only use the simple Generation command, and will not write a perfect makefile.


When I use this set of environment to try to compile STLport project, there is a situation where cl.exe exits directly. So in the end I also used the VS comes with Environment settings batch command: Vcvarsall.bat, sample in vs2012: C:\Program Files (x86) \microsoft Visual Studio 11.0\vc\ Vcvarsall.bat. You can compile the STLport-5.2.1 project by running this file in the current command window and loading the environment settings.


Reference link: VS2010 use STLport-5.2.1 excerpt:

Configure MSVC9 (Configure MSVC10 will show Unknown COMPILER:MSVC10, MSVC9 can)

Fixed, time: November 25, 2014. The current STLport native project is not configured with vs2012, vs2013, which means that the STL library will not support c++11 very high, but to know that c++99/03, 10, 12 are compatible. So even if we are not vs08 that is MSVC9 version, but also can compile this project (do not rule out a little syntax error, but we can rely on their own C + +, STL knowledge to deal with this compilation error, I configure the time only syntax error, modify it is available).

The next step was to use the NMAKE tool, and this time I found myself pulling out of the environment to compile a direct exit. Oops, forgot to record the error message. Cond

Based on this, I used the build variable setting for the VS band and finished compiling the STLport-5.2.1.


2, Cygwin environment use

Mark a reference or useful article first:

Baidu Library about Cygwin Environment Introduction UNIX environment Cygwin installation and usage Introduction Cygwin installation details and GCC compiler commands Baidu experience about STLport development environment configuration article

Gcc-makefile Getting Started There is also a tutorial makefile Getting started: Learn to write with me makefile

The underlying command is primarily the use of escape characters to implement the input of the full path:

$ cygpath-w/cygwin/c/program\ files/internet\ Explorer/iexplore. EXE C:\Program files\internet Explorer\iexplore. Exe

Examples of GCC compilations are as follows:

#include <iostream>using namespace Std;int main (int argv,char * * argc) {cout<< "Hello World,cygwin" << Endl;return 0;}

The next step is to use the Cygwin environment to compile the target file. Because of the use of STL, you must use g++ 's compile command:g++ hello.cpp// is already under this path, does not use the command character to compile

After the compilation is complete, the running discovery environment is incorrect and the DLLis missing. There are generally several solutions to this problem:

1) copy dll

2) by setting the window path environment variable

3) pre-compilation processing. At the current point in time, I tried to use the g++ -mno-cygwin hello.cpp to compile, found that the compilation failed, not supported. Cond



3, use makefile to compile another small project, from the reference link way, using my own code

Makefile content:

#jingz ' s first file to test makefilealltarget:stdafx_target 11_12_targetg++ stdafx.o 11_12.o-o 11_12.exe#remove the OBJEC  T FILESRM-RF stdafx.o 11_12.o#complie the CPPs into objectsstdafx_target:g++-C stdafx.cpp-o stdafx.o11_12_target:g++-C 11_12.cpp-o 11_12.O

Compile time will encounter some problems, such as the identification between the standard problems, TCHAR configuration problems. We need to configure the available STL standard libraries ourselves.

[Email protected]/cygdrive/d/cpp_lab_linux/11_12$ makeg++-C stdafx.cpp-o stdafx.og++-C 11_12.cpp-o 11_12.o11_12.cpp: In the function ' int main () ': 11_12.cpp:23:15: Error: ' nullptr ' has not been declared in this scope  int * temp = nullptr;               ^makefile:10:recipe for Target ' 11_12_target ' failedmake: * * * [11_12_target] Error 1

Cygwin simulates the UI operation of Unix. EXE is an executable file that executes the same way as Linux. The/11_12 can be printed out.


Here is the reprint link: Click to open the link

At present, the VC 9.0 with several STL defects, in order to ensure that the use of STL in any C + + compiler can be consistent, decided to unify the standard library as STLport. MinGW is used to use the Wstream wide character stream. The compilation process is generally recorded and can be a reference later. Compile version stlport-5.2.1  VS2008 (MSVC 9.0) under     (1) Unpack the package to a folder, such as D:\STLport (no spaces in the path)     (2) Start the VS2008 command line mode. (Note that not Run ...) CMD in)          CD d:\stlport    (3) Configure Msvc9-x-- With-static-rtl--use-boost D:\LIB\BOOST_1_36_0&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;MSVC9 indicates the compiler The         -x parameter indicates cross-compile, and a Vc9 folder is generated under the Lib folder. It doesn't matter if you add it.         --WITH-STATIC-RTL indicates the compilation of a static library, which is used when the compiler parameter chooses/MT.                  If you need a dynamic library, change with-dynamic-rtl                  It seems impossible to compile both dynamic and static libraries at the same time. It doesn't matter at one time.                  However, when you choose to compile a static library, the files of the dynamic library are also generated, but those are not available, and the file name also has an X letter indicating invalid files          --use-boost indicates the path to the boost library. Use only a few of the boost's header files, so you don't need to compile boost beforehand. There is no space in the path, otherwise it is troublesome     (4) CD build\lib         switch to Build\lib subdirectory     (5) Nmake/fmsvc.mak install          start compiling. Need to stay a while. Lib and DLL files are generated under Stlport\lib and Stlport\bin (when the dynamic library is completed).     (6) Start the VS2008 settings include directory. Note the position of the stlport\stlport in front of the STL library that the VC comes with. Finished ~ ----------------------------2009.11.1 supplement: Recently, according to the need to recompile again STLport, found previously written this article has a few questions. First, about the--use-boost option. STLport in 5.2.1 has been a long time, and during this period, the version of boost from 1.36.0 to 1.40.0, so STLport in the--use-boost option looks and the new version of Boost has not been very good collaboration. So do not specify this option, originally this to Win32 VC is not very necessary. Second about--with-static-rtl and--with-dynamic-rtl, the previous understanding is wrong. --with-static-rtl the C Runtime library (i.e. LIBCMT.lib), which is statically linked to the VC at compile time, so that the compiled library, we will later build our own program when the/MT option is used。 If there are no other changes, the default is statically linked to the STLport library, if you want to statically link to the C Runtime Library while dynamic link to stlportxx.dll, then in their own project properties to add _stlp_use_dynamic_ LIB's predefined macros. This will use a generation file with the letter x (the above said with X is invalid file, because it will not be used, hehe. --with-dynamic-rtl the C Runtime library (i.e. MSVCxxx.lib MSVCP90.dll), which indicates that the compile-time link is dynamically linked to the VC, so that the compiled library will be used to select the/MD option when building its own program. 。 If there is no other change, the default is also dynamically linked to the STLport library (dependent on stlport.5.2.dll), if you want to dynamically link to the C Runtime Library while static link to stlportxx.lib, then add _stlp_ in the project properties Use_static_lib the predefined macros. (Some other files with an X-letter are also used.)   Now compile the words and do it directly: (1) Configure Msvc9-x--with-dynamic-rtl (2) switch to Build/lib directory, Nmake/fmsvc.mak install clean (3) confi Gure msvc9-x--with-static-rtl (4) switch to Build/lib directory, Nmake/fmsvc.mak install clean Complete ~ Generate file in/LIB/VC9 and/BIN/VC9 directories.  stlport used to be really cool, more efficient than the VC9 own STL library, especially for C + +  stream IO operation optimization is very good, basically can exceed the efficiency of C library functions. ----------------------------------------  However, the use of VC STLport also found a small problem, mainly with the VC debugger is not good, because some of the STLport standard container structure becomes more complex, It seems that it is not easy to observe the changes in the data during single-step debugging.   II, MinGW (GCC 3.4.5) under        (1) Start MSYS & cd/lib/stlport-5.2.1
(2) Configure--WITH-BOOST=/LIB/BOOST_1_36_0
# do not have spaces in the middle of the boost path, or it will be hard to do later
(3) CD Build/lib
(4) Mingw32-make-f Gcc.mak all
# Use the make of MinGW, don't use the MSYS
# Copy. A and. dll files to stlport/lib and Stlport/bin respectively after compiling
# All option default build all dynamic libraries, to compile the static library must be specified as follows:
(5) mingw32-make-f Gcc.mak release-static dbg-static stldbg-static
# Three types of static libraries are compiled. Also copy. A files to Stlport/lib
(6) Set the include for MinGW:
This seems to only specify the parameter-I and-l at compile time
(7) Parameters for use
--Dynamic Link:
g++ xxx.cpp-mthreads-i/lib/stlport5.2.1/stlport-l/lib/stlport5.2.1/lib/mingw-lstlport.5.2
--Static Link:
Add at the beginning of the source file: #define _stlp_use_static_lib
g++ xxx.cpp-mthreads-i/lib/stlport5.2.1/stlport-l/lib/stlport5.2.1/lib/mingw-lstlport
# The last library name does not have a version number compared to the dynamic link version
# to link the debug version only need to change the last library name to the appropriate name, such as-LSTLPORTG originally written one months ago ... The result of a holiday to give the days of Space Live was sealed ... And then it took so long = = still lazy ~ and then a little complaining. Fancy instruments generally said inside the wrong pile of words inaccurate what, said computer books to see the original quality, the results of this is supposed to be STL standard Learning manual "C + + Stardand library:a Tutorial and Reference" is also a frequent error, What kind of all have ... The function name is wrong, the algorithm is written wrong, the time complexity is wrong, the function return value is true false, and there are many typographical errors that are not listed. Of course, the content of the book is very good, just look at the time to be careful ...

STLport-5.2.1 STL port configuration, cl.exe compiled Cpp:ms and Cygwin two modes, Cygwin environment configuration and usage, GCC compilation primer

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.