2

I am trying to install Boost.Python on my computer. (Windows7 64bit, Visual Studio 2012, Python 2.7 64bit and Boost 1.54)

Following the instruction, I've successfully installed the Boost Library, and then I have to separately install Boost.Python.

However, as I followed the instruction at here. I am stuck at step 3.1.4.

I input C:\boost_1_54_0\…\quickstart> bjam toolset=msvc --verbose-test test

Then there are 135 unresolved external errors pop out. One of them is:

exec.obj : error LNK2019: unresolved external symbol __imp__PyEval_GetGlobals referenced in function "class boost::python::api::object __cdecl boost::python::eval(class boost::python::str,class boost::python::api::object,class boost::python::api::object)" (?eval@python@boost@@YA?AVobject@api@12@Vstr@12@V3412@1@Z)........\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_54.dll

May I know how can I work around this?

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

Edit:

Following @Kyle 's advice, I've uninstalled the 64bit Python and replace it with a 32bit Python (2.7.5).

Then I've wrote a very simple code, which is like follows:

#include <boost\python.hpp>       // This header used to raise error before
#include <Python.h>
using namespace std;

void main()
{
    return;
}

It works well. Then my curiosity pushed me one step further, and I tried the example in my first post. It turns out that those 135 unresolved external errors are gone. Instead, I've got this:

msvc.link.dll bin\msvc-11.0\debug\extending.pyd LINK : fatal error

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

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86

nullink /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-11.0\debug\extending.pyd" /IMPLIB:"bin\msvc-11.0\debug\extendi ng.lib" /LIBPATH:"C:\Python2.7.5\libs"
@"bin\msvc-11.0\debug\extending.pyd.rsp "

    if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

...failed msvc.link.dll bin\msvc-11.0\debug\extending.pyd

bin\msvc-11.0\debug\extending.lib bin\msvc-11.0\debug\extending.pdb...

...skipped test_ext for lack of extending.pyd...

msvc.link bin\test_embed.test\msvc-11.0\debug\test_embed.exe LINK : warning

LNK4001: no object files specified; libraries used LINK : error

LNK2001: unresolved external symbol _mainCRTStartup

bin\test_embed.test\msvc-11.0\debug\test_embed.exe : fatal error

LNK1120: 1 unresolved externals

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 nul

link /NOLOGO /INCREMENTAL:NO /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console

/out:"bin\test_embed.test\msvc-11.0\debug\test_embed.exe"

/LIBPATH:"C:\Python2.7.5\libs"

@"bin\test_embed.test\msvc-11.0\debug\test_embed.exe.rsp"

    if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

...failed msvc.link bin\test_embed.test\msvc-11.0\debug\test_embed.exe

bin\test_ embed.test\msvc-11.0\debug\test_embed.pdb...

...removing bin\test_embed.test\msvc-11.0\debug\test_embed.pdb

...skipped test_embed.run for lack of test_embed.exe...

...failed updating 5 targets...

...skipped 4 targets...

Sorry to bother you with a large chunk of error message, I just want to provide as more information as I can.

About this boost_python-vc110-gd-1_54.dll, I can find it at C:\local\boost_1_54_0_32bit\lib32-msvc-11.0, while the root of my Boost is C:\local\boost_1_54_0_32bit\.

Can anyone help me work around with this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ChangeMyName
  • 7,018
  • 14
  • 56
  • 93
  • 1
    This looks as though it is the same question as the one posted [hours earlier](http://stackoverflow.com/questions/19002587). If they are the same, then please elaborate on the problem in a single question, rather than creating duplicates. – Tanner Sansbury Sep 25 '13 at 16:21

2 Answers2

2

Like Kyle C mentioned, this is happening because it can't find the lib. If you want to use 64-bit, you need to specify address-model=64 on the command line, plus have the 64-bit version of python correctly specified in your user-config.jam file.

I documented what I had to do to get this running, see the bottom for 64-bit specific config.

teeks99
  • 3,585
  • 2
  • 30
  • 38
1

This means that the linker can't properly link to the Python lib. I have run into this before when trying to link to 64bit Python. You should try installing 32bit python and see if that works.

Kyle C
  • 1,627
  • 12
  • 25
  • Hi, Kyle. Thanks for your advice. May I know how did you solve it? By installing a 32bit Python? I'm afraid that I cannot change Python version due to system limitation. – ChangeMyName Sep 25 '13 at 15:46
  • 1
    Correct, I solved it just by installing 32bit Python. I'm not sure what the details are around linking 64bit Python, but perhaps that can get you looking in the right spot. – Kyle C Sep 25 '13 at 15:52
  • Yes, thanks. Inspired by you, I'm trying to build Boost.Python in different ways. Would you mind tell me what was your system? Many thanks. :) – ChangeMyName Sep 25 '13 at 15:57
  • 1
    Sure, I had a very similar setup. Win 7 64bit, 32bit Python, VS 2012, Boost 1.54. – Kyle C Sep 25 '13 at 15:59