乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      boost_python寫擴(kuò)展

       londonKu 2012-03-28

      Boost版本號(hào)1.34.1

      可以google并參考一篇叫"混合系統(tǒng)接口Boost.Python"的文章
      還有
      http://wiki./moin/boost.python/HowTo


      http://learn.:8080/2005212716/html/boost_python.html


      http://visnuhoshimi.spaces./blog/cns%2135416B2A4DC1B31B%211863.entry



      1.bjam python
      2.把生成*.lib復(fù)制到庫目錄(可以在djam的輸出中看到路徑)
      3.
      進(jìn)入Boost目錄下的“l(fā)ibs\python\build\VisualStudio”子目錄中,在VC中打開其中的“boost_python.dsw”文件。
      分別編譯Boost.Python的Debug和Release版。
      編譯完成后將在Boost目錄下的“l(fā)ibs \python\build\bin-stage”子目錄中生成動(dòng)態(tài)鏈接庫和庫文件復(fù)制出來
      4.
          設(shè)置好包含文件,庫的路徑
          有以下內(nèi)容:
              python的include和lib
              boost的include以及上面生成的lib
             
      5.
      VC中
          項(xiàng)目->配置屬性->常規(guī)->配置類型 改為.dll
      6.
      編譯
      char const* greet()
      {
         return "hello, world";
      }

      #include <boost/python/module.hpp>
      #include <boost/python/def.hpp>
      using namespace boost::python;

      BOOST_PYTHON_MODULE(hello)
      {
          def("greet", greet);
      }

      將生成的dll改名為hello.pyd
      可以復(fù)制到python25\dlls下面,也可以在當(dāng)前目錄
      結(jié)合步驟3生成的dll就可以看到輸出了

      import hello
      print hello.greet()
      raw_input()

      7.
      封裝一下,把參數(shù)和返回值都封裝成python的類型,

      #include <boost/python.hpp>
      //先包含字典
      #include <boost/python/dict.hpp>
      class SearchPy{
          ...
          dict search(char* content){
              vector<string,int> result=_search.search(content);
              dict k_c;
              //將原來的返回值封裝成Python的字典格式
              for(vec_key_ptr::iterator i=result.begin();i!=result.end();++i)
                  k_c.setdefault(i->keyword,i->count);
              return k_c;
          }
      };

      BOOST_PYTHON_MODULE(search){

         class_<SearchPy>("Search", init<>())
               .def("search", &SearchPy::search)
              //............................
          ;

      }

      ok,大功告成,可以在python中掉C++了

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多