VS2010编译使用STLport与boost

Win7下编译STLport 5.2.1 与 boost_1_54_0的方法

(一)编译STLport:

  1、打开VS2010的 “Visual Studio Command Prompt (2010)” 工具

  2、进入到STLport的解压目录,而且在该目录下可以看到“configure.bat”

  3、cd 进入STLport目录下

  4、输入 “configure msvc9

  5、输入 “cd build/lib

  6、输入 “nmake clean install”

  7、可以将“../build/lib"目录下的obj目录删除。

  可能出现错误如:

    error C2084: function'__int64 abs(__int64)' already has a body

  解决方法:

    1、打开你的STLport目录stlportstl下的_cstdlib.h,用vs2010或者其它工具

    2、将158行:

        158 inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }

      变成

        #if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600)
        inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { 
return __x < 0 ? -__x : __x; }
        #endif

(二)用STLport编译boost_1_54_0

  1、打开VS2010的 “Visual Studio Command Prompt (2010)” 工具

  2、进入到boost解压目录,在该目录下可以看到“bootstrap.bat”

  3、cd boost目录

  4、输入 “bootstrap.bat”

  5、则在当前目录下会生成一个bjam.exe的应用程序

  6、进入到 “boos目录/tools/build/v2”,在该目录下找到user-config.jam这个文件,以文本的形式打开,在文本的最后添加:“using stlport : 5.2.1 : 你的STLport目录/stlport ;”,一定得注意“:”与“;”前有一个空格,否则,执行会失败。

  7、输入 “bjam --toolset=msvc-10.0 --build-type=complete stdlib=stlport stage”

(三)不用STLport编译boost_1_54_0

  在上面的第6步:输入“.2”,而且这种方法比较快。

(四)针对boost,其实我们可以嵌入自己的工程编译(《boost程序库完全开发指南》),也就是说我们只需要解压即可。但是这样可以就不会使用STLport编译了。

(五)将STLport目录与Boost目录加入到VS2010中。

  在“VC++Directories”的“Include Directories”中增加boost目录与STLport目录

原文地址:https://www.cnblogs.com/wang-can/p/3338942.html