Embedded Python interpreter, runtime libs, and crashing

Peter Newman panewman at uiuc.edu
Wed Oct 26 05:28:13 CEST 2005


I'm embedding a Python interpreter into a project, and compiling with
MSVC.  It all runs great in the "Debug" configuration, but everything
gets scary when I switch to "Release".

I've read about things that can go wrong when you use the wrong runtime
library when compiling a program that uses Python.  I've done my best to
follow the suggestions I've read, but I still seem to be having trouble.
Here's a summary of how I've configured my project:

Release:
========
- C/C++->Code Generation->Runtime Library: Multithreaded DLL
- Linker->Input->Additional Dependencies: ... python24.lib
- Output EXE runs beside Python24.dll

Debug:
======
- C/C++->Code Generation->Runtime Library: Multithreaded Debug DLL
- Linker->Input->Additional Dependencies: ... python24_d.lib
- Output EXE runs beside Python24_d.dll


The debug configuration works flawlessly.  Release is another story
altogther.  It usually crashes with a segmentation fault or access
violation (reading memory address 0).  At one point it ran, but the code
seemed to be executing in the wrong order (stuff getting called before
initialization functions were finished, etc.)


-- 
Peter Newman (panewman at uiuc.edu)



More information about the Python-list mailing list