0

I posted about this problem a few days ago (now deleted), but have since gotten closer to a solution and therefore, I think, better able to ask a constructive question.

I am trying to use Boost.Python in Visual Studio to build a basic C++ 'hello world' function as a .pyd file; my process is as follows:

  • Create new empty project
  • Set target extension to .pyd and configuration type to .dll
  • Include and link necessary Python folders per this guide under the section "Create the core C++ project"
  • Import VS2017 Boost.Python3 package via package manager console (PM> Install-Package boost_python3-vc141 -Version 1.65.1)

Then I copy a basic 'hello world' function and wrapper from this website:

#define BOOST_PYTHON_STATIC_LIB
#include <boost/python.hpp>

char const* greet()
{
    return "hello, world";
}

BOOST_PYTHON_MODULE(hello_ext)
{
    using namespace boost::python;
    def("greet", greet);
}

However, upon attempting to build the solution, I receive the error, "LNK1104 cannot open file 'python27.lib'" I think that my problem is similar to this question, but I tried creating a 'user-config.jam' file in my home directory:

import toolset : using ;
using python : 3.6 : C:\Program Files\Python36\python.exe ;

And I continue to receive the same error message.

How do I force Boost.Python3 to use Python 3.6 instead of the 'default' Python 2.7?

KPM
  • 331
  • 1
  • 13
  • Keep in mind that Python2 and Python3 code is not always compatible. Meaning; not all Python2 code is valid Python3 and vice versa. They bumped that version number for a reason. – Jesper Juhl Nov 09 '17 at 20:49
  • @Jesper Thanks for the clarification, but that's exactly the problem: I'm using Boost.Python3 instead of Boost.Python (2) to avoid issues with legacy code, but Boost insists on trying to find the Python2 LIB file anyway. I have nothing related to Python2 installed on my machine. – KPM Nov 13 '17 at 13:34

0 Answers0