linking problem when including python in C++ file on Visual Studio 2017

Elinor Ginzburg 106 Reputation points
2020-08-30T07:21:31.637+00:00

Hello,

I'm building user interface for usb device using MFC application on Visual Studio 2017 in C++. I've written a short script in python to read some data from a file, which I wanted to use in my program.

I've downloaded all the necessary packages for python which are specified in the Visual Studio guide here

I've added in Project -> Properties -> C\C++ -> All Options -> Additional Include Directories the path to Microsoft Visul Studio\Shared\Python36_64\include.

I also specified this path in the Linker -> Input -> Additional Dependencies.

and I've checked all .pdb files from the folder Python36_64 are specified in the debugging symbols

The problem is, that when I try to build the solution I get the following error:

LNK1104 cannot open 'C:\Program Files (x86)\Microsoft Visul Studio\Shared\Python36_64\include.obj

When I checked, the file include.obj isn't generated (it doesn't exist) but I don't know what do I need to do in order to create it.

I believe the problem is with my project\linker properties, but I'm not sure what exactly. I think so since when I create new python project I have no problems running python code and when I clear the include python.h my app runs perfectly. How can I solve it?

Thank you.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,171 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,753 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 31,006 Reputation points Microsoft Vendor
    2020-08-31T09:27:43.007+00:00

    Hello Elinor,

    Please try Viorel’s suggestions and also kindly follow steps below to reconfigure the settings and rebuild your project to see if this works.

    1. Right-click the C++ project > Properties > Configuration Properties > C/C++ > General > Add the include directory to “Additional Include Directories”. The directory should be like this C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\include.
    2. Right-click the C++ project > Properties > Configuration Properties > Linker > General > Add the libs directory to “Additional Library Directories”. The directory should be like this C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\libs.

    Sincerely,
    Tianyu

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.