Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Python 3.3 in C++ 'python33_d.lib' not found

I am trying to #include <Python.h> in my C++ code and when I go to compile my code I get this error:

fatal error LNK1104: cannot open file 'python33_d.lib'

I have tried to find python33_d.lib on my computer to include in my linker dependencies, but I cannot find it. I have been able to find python33.lib.

Where can I find the python33_d.lib, or how can I resolve this issue?

like image 952
user1334858 Avatar asked Jun 10 '13 16:06

user1334858


3 Answers

Simple solution from the python bug tracker:

#ifdef _DEBUG
  #undef _DEBUG
  #include <python.h>
  #define _DEBUG
#else
  #include <python.h>
#endif
like image 104
liorda Avatar answered Nov 13 '22 03:11

liorda


In the event that you need a debug version (as I do for work), it is possible to build the library yourself:

  1. Download the source tarball from http://www.python.org/download
  2. Extract the tarball (7zip will do the trick) and go into the resulting directory (should be something like Python-3.3.2).
  3. From the Python directory, go to the PCBuild folder. There are two important files here: readme.txt, which contains the instructions for building Python in Windows (even if it uses the UNIX line feed style...), and pcbuild.sln, which is the Visual Studio solution that builds Python.
  4. Open pcbuild.sln in Visual Studio. (I am assuming you are using Visual Studio 10; readme.txt contains specific instructions for older versions of Visual Studio.)
  5. Make sure Visual Studio is set to the "debug" configuration, and then build the solution for your appropriate architecture (x64 or Win32). You may get a few failed subprojects, but not all of them are necessary to build python33_d; by my count, 8 builds failed and I got a working .lib file anyway.
  6. You will find python33_d.lib and python33_d.dll in either the PCBuild folder (if building Win32) or the amd64 subfolder (if building x64).
like image 25
J.T. Davies Avatar answered Nov 13 '22 01:11

J.T. Davies


*_d.lib is used for debug builds. Switch to a release build instead.

like image 18
Ignacio Vazquez-Abrams Avatar answered Nov 13 '22 01:11

Ignacio Vazquez-Abrams