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

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    WDK7.6配置使用STL

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/62532

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 上午10:27
下一篇 2023年2月9日 上午10:28

相关推荐