我目前正在尝试在Windows(使用英特尔编译器)上构建一个在UNIX上使用CMake编译得非常好的大项目.这是我的问题的简单示例.
使用Boost.Python运行以下简单的代码示例:
#include <iostream>
#include <Python.h>
#include <boost/python.hpp>
int main()
{
std::string python_home = "C:\\softs\\python\\2.7.9\\64";
char* python_home_char = new char[python_home.length() + 1];
strcpy(python_home_char, python_home.c_str());
Py_SetPythonHome(python_home_char);
Py_Initialize();
boost::python::object pyobj_main = boost::python::import("__main__");
boost::python::object glob = pyobj_main.attr("__dict__");
boost::python::exec("print \"Hello from Python\"", glob, glob);
Py_Finalize();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
执行代码时出现以下错误消息:
程序无法启动,因为您的计算机缺少boost_python-iw-mt-1_57.dll.尝试重新安装该程序以解决此问题.
请注意,如果删除boost::python::***代码末尾的3行,我没有错误.另外,如果我使用Boost.Thread编译以下示例,我没有任何错误(在我看来,它也使用库(不是标题),是不是?):
#include <iostream>
#include <boost/thread.hpp>
boost::mutex mutex_hello;
void hello(unsigned long int thread_number)
{
boost::mutex::scoped_lock lock_hello(mutex_hello);
std::cout << "Hello from thread " << thread_number << std::endl;
}
int main()
{
boost::thread_group group;
for(unsigned …Run Code Online (Sandbox Code Playgroud)