New submission from Joakim Karlsson:

When I embed Python 3.4 in an existing app, I run in to a few issues when our 
app is built in debug mode. I build against the headers, libs and dlls that I 
get when installing python, I don't build python myself.

1. When I include python.h it will, via pyconfig.h, automatically attempt to 
link to python34_d.lib. This lib, along with its accompanying dll is not 
included in the python installation.

I'd rather explicitly link to the release lib than having header files 
implicitly selecting libs based on the _DEBUG flag. I ended up killing the 
#pragma comment(lib...) statements in pyconfig.h, and I can now link with the 
lib included.

2. Now when I build, I get a linker error telling me that '__imp__Py_RefTotal' 
and '__imp_Py_NegativeRefCount' cannot be found. This seems to be caused by 
Py_DEBUG being defined automatically in pyconfig.h as a result of _DEBUG being 
defined for my application. This causes the reference counting macros to use 
functionality that is only present in the debug version of python34.dll.

I ended up including pyconfig.h first, undefed Py_DEBUG, and then including 
python.h. This seems rather clunky.

Keeping with "explicit is better than implicit", wouldn't it be better to 
having to explicitly link to the desired lib from the embedding app, and 
explicitly set Py_DEBUG without having it inferred from _DEBUG? 

That way the provided headers and libs would work right out of the box while 
still leaving me the option to get the debug behaviour if I need to.

----------
components: Windows
messages: 226882
nosy: Joakim.Karlsson
priority: normal
severity: normal
status: open
title: Embedding Python on Windows
type: compile error
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22411>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to