0

My Qt project links with the library python27.lib on Windows 8.1. The .pro file contains the following line:

win32:LIBS += C:\Python27_11\libs\python27.lib

When building the project in Release mode, it links correctly with python27.lib.

When building the project in Debug mode, it looks for python27_d.lib:

Error: LNK1104: cannot open file 'python27_d.lib'

How to enforce linking with python27.lib in the Debug mode?

Thank you in advance!

Roni.

P.S. I tried to use different syntax win32:LIBS += -LC:/Python27_11/libs -lpython27, and to enclose the declaration into CONFIG(debug, debug|release) {}. None of these worked.

The system info: Qt Creator 3.5.1 (opensource) Based on Qt 5.5.1 (MSVC 2013, 32 bit) The OS is Windows 8.1 Pro 64 bit

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
roni
  • 1
  • You basically need to get the debug version of the Python library, I believe (could be wrong, I usually use MinGW for Windows stuff, but see the suggested duplicate). – hyde Jun 01 '16 at 20:16
  • I'm pretty sure it's one of the python headers that opens the "_d.lib" if one of the "DEBUG" or "_DEBUG" macros are set, I don't think this is a qtcreator thing – PeterT Jun 01 '16 at 20:43
  • Thank you, @hyde, both for the link and for the suggestion. In this particular case I could probably build Python debug library from the source (it is not available pre-built). However I ran into a similar problem before. Sometimes the 3d party libraries are not available in both release and debug version. I would like to to control what library I am linking with, instead of QtCreator making decision for me (even if it is a good practice). – roni Jun 01 '16 at 20:44
  • @roni just do something like `#undef _DEBUG` before including python.h (and re-define it in debug mode afterwards) – PeterT Jun 01 '16 at 20:47
  • Thank you, @PeterT, you are probably right, in might not be QtCreator itself. I hope to find correct syntax/setting for the *.pro file that will enforce linking with the right library. – roni Jun 01 '16 at 20:53
  • again, nothing to do with the *.pro file QtCreator or qmake, somewhere in the python header there's a `#pragma comment(lib,"python27_d.lib")` – PeterT Jun 01 '16 at 20:55
  • Thank you very much, @PeterT! The "#undef _DEBUG" solution worked! – roni Jun 01 '16 at 21:00
  • just don't forget to re-enable it in debug mode like in this answer: http://stackoverflow.com/a/32425901/777689 – PeterT Jun 01 '16 at 21:02
  • Yes, that is exactly what I used. Thanks again! – roni Jun 01 '16 at 21:14

0 Answers0