Boost.Python can't link using downloaded pre-compiled binaries
Following are the environment: - Windows 7 Enterprise SP1 64 bit - Python 2.7.13 - Visual Studio 2015 (v14.0) Following are the steps to the problem: (1) I downloaded boost_1_64_0-msvc-14.0-64.exe from https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceforge.net_projects_boost_files_boost-2Dbinaries_1.64.0_&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=uu0095bHyY4u8_4aL_8VSkoBAibccyzY1AWGIZA2kCM&m=VSW-VsQfEXq3HBydeHEvLNNj_uycGGoKJROuR73u4zs&s=YalbXHrjJuRH5y-VhXT4u0sM6Bbq9HArvy2EpPpppcs&e= . Since it is pre-compiled binary, I think there is no need to build Boost.Python manually. Note that it is for 64 bit build in VS2015 if I understand correctly. (2) Install the pre-compiled binary to C:\local\boost_1_64_0 (3) Follow the Boost.Python's QuickStart here: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.boost.org_doc_libs_1-5F49-5F0_libs_python_doc_tutorial_doc_html_index.html&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=uu0095bHyY4u8_4aL_8VSkoBAibccyzY1AWGIZA2kCM&m=VSW-VsQfEXq3HBydeHEvLNNj_uycGGoKJROuR73u4zs&s=gBej1dWvGIQEAbW0ZO1f254j3n3sAmQ1_jfuMqWGZ8s&e= . The source code are the same as shown therein. (4) Set in VS2015 Property Pages->C/C++->Additional Include Directories: C:\local\boost_1_64_0;C:\Python27\include Set in VS2015 Property Pages->Linker->Additional Library Directories: C:\local\boost_1_64_0\lib64-msvc-14.0;C:\Python27\libs Set in VS2015 Property Pages->Linker->Input->Additional Dependencies: boost_python-vc140-mt-1_64.lib;boost_python-vc140-mt-gd-1_64.lib;%(AdditionalDependencies) Set in VS2015 Property Pages->General->Configuration Type: Dynamic Library (.dll) (5) Build under x64 configuration and got errors: 1>Source.obj : error LNK2001: unresolved external symbol __imp_PyString_Type 1>Source.obj : error LNK2001: unresolved external symbol __imp__Py_NoneStruct 1>C:\...\ConsoleApplication1\x64\Release\ConsoleApplication1.dll : fatal error LNK1120: 2 unresolved externals I have no idea what the matter is. I will greatly appreciate it if you can help me out.
On 25/05/2017 15:01, Heng Zhou wrote:
(5) Build under x64 configuration and got errors: 1>Source.obj : error LNK2001: unresolved external symbol __imp_PyString_Type 1>Source.obj : error LNK2001: unresolved external symbol __imp__Py_NoneStruct 1>C:\...\ConsoleApplication1\x64\Release\ConsoleApplication1.dll : fatal error LNK1120: 2 unresolved externals
I have no idea what the matter is. I will greatly appreciate it if you can help me out.
I don't use Boost.Python myself so I can't give you more specific instructions, but unresolved externals of __imp_* symbols mean that you need to add an import library (the .lib) for a DLL, either by adding a reference to it or by adding it to the linker project settings. Given the names of the symbols, it's most likely one of the Python runtime DLLs.
Link your C++ module with Python27.lib . Boost.Python is only the wrapper of Python binding so if your module is static, it absolutely needs the Python27.lib . Even we might use dynamic boost.python , but host application might still require Python27.lib if there are any Python APIs called. On Tue, May 30, 2017 at 3:01 PM, Gavin Lambert via Boost-users < boost-users@lists.boost.org> wrote:
On 25/05/2017 15:01, Heng Zhou wrote:
(5) Build under x64 configuration and got errors: 1>Source.obj : error LNK2001: unresolved external symbol __imp_PyString_Type 1>Source.obj : error LNK2001: unresolved external symbol __imp__Py_NoneStruct 1>C:\...\ConsoleApplication1\x64\Release\ConsoleApplication1.dll : fatal error LNK1120: 2 unresolved externals
I have no idea what the matter is. I will greatly appreciate it if you can help me out.
I don't use Boost.Python myself so I can't give you more specific instructions, but unresolved externals of __imp_* symbols mean that you need to add an import library (the .lib) for a DLL, either by adding a reference to it or by adding it to the linker project settings.
Given the names of the symbols, it's most likely one of the Python runtime DLLs.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Bo Zhou
-
Gavin Lambert
-
Heng Zhou