473,287 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Linking debug C++ DLL with python dlls

Hi,

I am working with C++ code that needs to be maintained both in debug
and release versions. The environment is Windows 32 bit with MSVC8.

I downloaded the python installation for Win32 and installed it.
When, however, I tried to compile my DLLs in debug mode i got link
errors specifying that I need the python25_d.lib.

this is the code that generates the dependency on the python25_d.lib
in the <pyconfig.h>
#ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
# ifdef _DEBUG
# pragma comment(lib,"python25_d.lib")
# else
# pragma comment(lib,"python25.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

So I decided to download and build the debug version of python2.5.1/
As it seems I also need to compile all relevant extension modules
(*.pyd) in debug as well - is this correct?

I tried to change the code above (just for fun) so in both cases i'll
use python25.lib and in debug compilation I got linker errors on
unresolved externals. seems like the debug version exports more
methods than the release version.

Is there a way to have my C++ code compile in debug mode (with _DEBUG)
but use the python25 release lib/dll? This way I don't need to have
additional set of debug extension modules.

Thanks,
Moshe.

Nov 8 '07 #1
1 3407
So I decided to download and build the debug version of python2.5.1/
As it seems I also need to compile all relevant extension modules
(*.pyd) in debug as well - is this correct?
That's correct.
I tried to change the code above (just for fun) so in both cases i'll
use python25.lib and in debug compilation I got linker errors on
unresolved externals. seems like the debug version exports more
methods than the release version.
Correct.
Is there a way to have my C++ code compile in debug mode (with _DEBUG)
but use the python25 release lib/dll? This way I don't need to have
additional set of debug extension modules.
Try removing the definition of Py_DEBUG that is implied by _DEBUG.

Notice, however, that it is risky to mix different CRT versions
(debug and nodebug) in a single application; this could cause memory
leaks and crashes. In particular, it *will* cause crashes if you
pass FILE* opened by the debug CRT to PyRun_File and friends. That's
an inherent limitation of Windows DLLs, and the way Microsoft set
up global variables in the VC CRT.

Regards,
Martin
Nov 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shankar KN | last post by:
Hi, I have a system where all my binaries (built in Debug mode) are deployed on Windows XP Professional. These are C++ DLLs that expose a Python interface using SWIG. I have installed Python...
3
by: mep | last post by:
Hi, all I view my python 2.3.4 from python.org by VC6's dependency walker tool. What suprise me is that python.exe and python32.dll are built into *DEBUG* version. Is it intend to do so?Is a...
3
by: DE | last post by:
Hello, I have a problem with python builds since some time. On windows, it is not a good idea to link your debug build to release builds of libs and dlls. But python installer gives you...
5
by: J | last post by:
Hi everyone, I started embedding python into a 3D graphics App and I came across this linking problem. SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol...
2
by: | last post by:
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled within Visual Studio .NET 2003). Am trying to link simple c++ code to fortran dlls created in Compaq Visual Fortran (v6.1)....
1
by: Andras Balogh | last post by:
The project I'm working on is written mainly C/C++, spiced with some Python scripts. Now, I have several dlls, which work both as a Python extension modules, exporting functions to Python via...
6
by: Chris Stankevitz | last post by:
At link time, MSVC determines some of my libraries are unused and doesn't link them into my exe. This undesirable feature causes problems when I employ the factory pattern. With the factory...
0
by: JohnIdol | last post by:
VC++6 to VC++2003 - linking troubles -------------------------------------------------------------------------------- Hi All, I successfully ported an application from VC++6 to VS2003. Solved...
4
by: =?Utf-8?B?QldC?= | last post by:
We have a mixed application that includes managed and unmanaged code. Until recently we've been able to remote debug by disabling the security policy to get the MFC managed dlls to load properly...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.