WDK7.6配置使用STL

WDK7.6作为编译器,编译源码项目时,需要在源码相同目录下配置sources文件(没有任何后缀)。

本例运行环境:

  • Windows7-64bit
  • CPU: Intel i5 2400
  • WDK(WindowsDriveKit)7.6
  • Boost library version: 1.51.0

备注:开发中,将VS2010作为代码编辑器,WDK7.6作为编译器。


项目文件列表:

  • HelloWorld.cpp
  •  source

HelloWorld.cpp源码:

#include <iostream>
#include <vector>
#include <string>

#include <boost/array.hpp> 
#include <boost/lexical_cast.hpp>

#define outi(int_var) printf("%d", int_var)
#define outs(str) printf("%s", str)
#define newline() printf("\n")

void InvokeVector()
{
    //invoke STL's vector
    std::vector<std::string> vec;
    vec.push_back("Entry ");
    vec.push_back("of ");
    vec.push_back("Vector");
    vec.push_back("……\n");
    //print vec
    for (int i=0; i<vec.size(); i++) {
        std::cout<<vec.at(i);
    }
}

void invokeLexical_cast()
{
    int i = boost::lexical_cast<int>("256");
    outs("Cast string to int by Boost: ");
    outi(i);
    newline();
}

/*
   This class to show people wdk can support an C plus plus project.
*/
class Human
{
public:
    void singing()
    {
        outs("A man singing a beautiful song in the beach.\n");
    }
};

int main()
{
    outs("Entry of hw [16:36 Sep 12, 2012]\n");
//    InvokeVector();
    invokeLexical_cast();
    Human h;
    h.singing();
    return 0;
}

sources文件配置:

TARGETTYPE=PROGRAM
TARGETNAME=helloworld

UMENTRY=main
USE_MSVCRT=1

#
#  指定使用STL和STL版本(默认为7.0) 
#  使用此两句配置,可在源码中引入C++的<iostream>\<string>\
#  以及<vector>\<map>等STL库头文件
#
USE_STL=1
STL_VER=70

#
# my boost library root directory
#
BOOST_INC_PATH=E:\lib\boost_1_51_0

INCLUDES=$(BOOST_INC_PATH)

TARGETLIBS=$(SDK_LIB_PATH)\user32.lib

SOURCES=HelloWorld.cpp

UMTYPE=console
UMBASE=0x4000000


使用WDK的Free build environment 工具进入源码目录,运行build /wcbg编译:

path contains nonexistant c:\program files (x86)\amd app\bin\x86, removing
BUILD: Compile and Link for AMD64
BUILD: Loading e:\app\winddk\7600.16385.1\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Wed Sep 12 16:36:55 2012
BUILD: Examining f:\quickdisk\working\project\wdk_projects\blog_sample directory
 for files to compile.
    f:\quickdisk\working\project\wdk_projects\blog_sample Auto-cleaning queue fo
r 'root:amd64fre' (1 of 1 file(s) removed)
Invalidating OACR warning log for 'root:amd64fre'
BUILD: Saving e:\app\winddk\7600.16385.1\build.dat...
BUILD: Compiling and Linking f:\quickdisk\working\project\wdk_projects\blog_samp
le directory
Configuring OACR for 'root:amd64fre' - <OACR on>
Compiling - helloworld.cpp
Linking Executable - objfre_win7_amd64\amd64\helloworld.exe
BUILD: Finish time: Wed Sep 12 16:36:57 2012
BUILD: Done

    3 files compiled - 1 Warning - 52 LPS
    1 executable built


可执行文件路径 .\objfre_win7_amd64\amd64\HelloWorld.exe

执行结果:

Entry of hw [16:36 Sep 12, 2012]
Cast string to int by Boost: 256
A man singing a beautiful song in the beach.





转载于:https://www.cnblogs.com/qx-zhong/archive/2012/09/11/2939361.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值