zoukankan      html  css  js  c++  java
  • boost 系列 1:boost 直接使用

    PART 1
    windows

    1. 在www.boost.org的文档中:

        example program (不编译直接使用)

      #include <boost/lambda/lambda.hpp>
      #include 
      <iostream>
      #include 
      <iterator>
      #include 
      <algorithm>

      int main()
      {
          
      using namespace boost::lambda;
          typedef std::istream_iterator
      <int> in;

          std::for_each(
              
      in(std::cin), in(), std::cout << (_1 * 3<< " " );
      }

        2. 配置:
    • From Visual Studio's File menu, select New > Project…

    • In the left-hand pane of the resulting New Project dialog, select Visual C++ > Win32.

    • In the right-hand pane, select Win32 Console Application (VS8.0) or Win32 Console Project (VS7.1).

    • In the name field, enter “example”

    • Right-click example in the Solution Explorer pane and select Properties from the resulting pop-up menu

    • In Configuration Properties > C/C++ > General > Additional Include Directories(关键,添加下列路径到Include文件夹), enter the path to the Boost root directory, for example

      C:\Program Files\boost\boost_1_46_1

    • In Configuration Properties > C/C++ > Precompiled Headers, change Use Precompiled Header (/Yu) to Not Using Precompiled Headers.3

    • Replace the contents of the example.cpp generated by the IDE with the example code above.

    • From the Build menu, select Build Solution.

      然后可以运行。

     PART 2  Linux

    1.  Linux

      参考http://www.boost.org/doc/libs/1_46_1/more/getting_started/unix-variants.html

     example program (不编译直接使用)

    #include <boost/lambda/lambda.hpp>
    #include 
    <iostream>
    #include 
    <iterator>
    #include 
    <algorithm>

    int main()
    {
        
    using namespace boost::lambda;
        typedef std::istream_iterator
    <int> in;

        std::for_each(
            
    in(std::cin), in(), std::cout << (_1 * 3<< " " );
    }

    编译:

    c++ -I path/to/boost_1_46_1 example.cpp -o example
    关键是包含boost代码文件夹
    然后,同样可以直接运行。

  • 相关阅读:
    第二次冲刺-个人总结01
    构建之法阅读笔记03
    第一次冲刺-个人总结07
    第十四周总结
    第一次冲刺-个人总结07
    第一次冲刺-个人总结06
    第一次冲刺-个人总结05
    mysql优化
    springmvc常用注解标签详解
    弄懂JDK、JRE和JVM到底是什么
  • 原文地址:https://www.cnblogs.com/no7dw/p/2168031.html
Copyright © 2011-2022 走看看