如何在C ++中使用'boost_python-vc110-mt-gd-1_54.lib'? [英] How to use 'boost_python-vc110-mt-gd-1_54.lib' in C++?

查看:181
本文介绍了如何在C ++中使用'boost_python-vc110-mt-gd-1_54.lib'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用BoostPython编写C ++程序.

我的预设是:

a. Win32控制台应用程序.

b.属性-> C/C ++->常规->其他包含目录-> C:\ Python27 \ include; C:\ Program Files \ boost \ boost_1_54_0;

c.属性->链接器->常规->附加库说明-> C:\ Python27 \ libs;

d. Microsoft Visual Studio 2012速成版+ Python 27 + Boost 1.54

我的代码如下:

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

int main( int argc, char ** argv ) 
{
    return 0;
}

如您所见,该代码的主函数为空.而且我收到一条错误消息

错误LNK1104:无法打开文件'boost_python-vc110-mt-gd-1_54.lib'

我检查了boost('bootstrap.bat'+'bjam.exe')的安装,并在安装boost库的文件夹中搜索了'boost_python-vc110-mt-gd-1_54.lib',但什么也没发现.

我寻找了一些类似的帖子,与我的问题不同,他们错过的lib文件带有前缀"lib".另一方面,我发现解决方案

我发现出现了该错误,因为我的计算机中没有正确安装Boost库.实际上,密钥是bjam,必须运行它才能构建所有这些必需的库.

我建议任何其他遇到此问题的人,如果您不知道如何正确运行bjam,请去搜索Boost的预构建二进制文件.这样可以节省您很多时间.

I am trying to use BoostPython to write a program in C++.

My presettings are:

a. Win32 Console Application.

b. Property->C/C++->General->Additional Include Directories->C:\Python27\include;C:\Program Files\boost\boost_1_54_0;

c. Property->Linker->General->Additional Library Directions->C:\Python27\libs;

d. Microsoft Visual Studio 2012 Express Version + Python 27 + Boost 1.54

And my code is like follows:

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

int main( int argc, char ** argv ) 
{
    return 0;
}

As you can see, this code is with an empty main function. And I got an error message

error LNK1104: cannot open file 'boost_python-vc110-mt-gd-1_54.lib'

I checked the installation of boost ('bootstrap.bat'+'bjam.exe'), and I've searched within the folder where boost library installed for 'boost_python-vc110-mt-gd-1_54.lib', but found nothing.

I looked for some similar posts, unlike my problem, the lib file they missed was with a prefix 'lib'. On the other hand, I found this post is very similar to mine. But I found the OP made a mistake when he/her solve his/hers problem. That is, Boost is compatible with python 2.2 and its newer versions. And the rest of his answer is not helpful to me.

I guess this problem could because either I've done something wrong during installation, or I was wrong when I link the libs to my application.

Can anyone help me out of this? A detailed solution will be great. Many thanks. :)

==============================================================

EDIT:

I've reinstalled the Boost with a prebuilt binary file. Now I can link to the lib file the compiler asked for. However, new problems are raised. Now I have two new errors:

error LNK2001: unresolved external symbol __imp___Py_NoneStruct

error LNK1120: 1 unresolved externals

When I comment out the line #include <boost/python.hpp>, the above errors are gone.

I really cannot figure out the reason. Can anyone help me with this? Many thanks.

解决方案

I've found out the error is raised because the Boost library was not properly installed in my computer. Actually, the key is bjam, and it must be run to build all these necessary libraries.

I would suggest anyone else that encounter with this problem, if you don't know how to run a bjam properly, go to search for a prebuilt binary file of Boost. That could save you a lot of time.

这篇关于如何在C ++中使用'boost_python-vc110-mt-gd-1_54.lib'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆