boost 1.34 終于簡(jiǎn)化了內(nèi)嵌python的支持。
還支持了python2.5。
在中文windows下用vc8編譯boost的過(guò)程中,雖然仍有代碼頁(yè)字符警告,但是可以正常編譯成功,不再象1.33.1那樣造成正則表達(dá)式庫(kù)不修改源碼不能夠編譯通過(guò)的問(wèn)題了。
下面的例子是從boost文檔中來(lái)的:
BTW:
我用vc8編譯了全部的boost,然后,include加上lib目錄(內(nèi)僅有l(wèi)ib和dll文件),合計(jì)2.68GB。
還支持了python2.5。
在中文windows下用vc8編譯boost的過(guò)程中,雖然仍有代碼頁(yè)字符警告,但是可以正常編譯成功,不再象1.33.1那樣造成正則表達(dá)式庫(kù)不修改源碼不能夠編譯通過(guò)的問(wèn)題了。
下面的例子是從boost文檔中來(lái)的:
#include <iostream>
#include <string>
#include <boost/python.hpp>
#include <boost/ref.hpp>
#include <vector>
using namespace boost::python;
void greet()
{
object main = import("__main__");
object global(main.attr("__dict__"));
// Define greet function in Python.
object result = exec(
"def greet(a): \n"
" return 'Hello %s from Python!' % a \n",
global, global);
object greet = global["greet"];
list lst;
lst.append(1);
lst.append(2);
object r = greet(lst);
std::string message = extract<std::string>(r);
std::cout << message << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Py_Initialize();
greet();
system("Pause");
return 0;
}
#include <string>
#include <boost/python.hpp>
#include <boost/ref.hpp>
#include <vector>
using namespace boost::python;
void greet()
{
object main = import("__main__");
object global(main.attr("__dict__"));
// Define greet function in Python.
object result = exec(
"def greet(a): \n"
" return 'Hello %s from Python!' % a \n",
global, global);
object greet = global["greet"];
list lst;
lst.append(1);
lst.append(2);
object r = greet(lst);
std::string message = extract<std::string>(r);
std::cout << message << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Py_Initialize();
greet();
system("Pause");
return 0;
}
BTW:
我用vc8編譯了全部的boost,然后,include加上lib目錄(內(nèi)僅有l(wèi)ib和dll文件),合計(jì)2.68GB。