473,503 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3419
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
1022
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
3291
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
1861
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
6752
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
7226
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
1358
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
2548
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
1428
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
1530
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...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.