Форум сайта python.su
Здравствуйте.
Начал разбираться со SWIG, Visual Studio 2008, C++, Python 2.6, Windows 7. При билде проекта получаю ошибку python26_d.lib cannot be found. И действительно, такого файла нет в сборке питона. Есть описанное решение :
'''
This file is only used for Debug builds and is not included in the Python binary distribution. You must download the Python sources and build the LIB and the corresponding DLL yourself.
But be careful! When you link your extension module with the debug version of the Python interpreter, you can only import the module when python.exe is also a debug version. Otherwise, you will receive the error “Fatal Python error: Interpreter not initialized (version mismatch?).”
'''
Но проблемма в том, что код должен компилироваться на нескольких машинах. И делать сборку питона на каждой не представляется возможным. Посоветуйте как решить, что почитать.
Офлайн
Только-что нашел еще одно решение http://tutorial.debashis.net/?p=57
В принципе до него можно было и самому додуматься, но это же не кошерно …
Офлайн
Кошерное решение:
#ifdef _DEBUG
#define RESTORE_DEBUG_FLAG
#undef _DEBUG
#endif
#include <python.h>
#ifdef RESTORE_DEBUG_FLAG
#define _DEBUG
#endif
Офлайн
Хитро, но к сожалению Visual Studio тоже не пальцем деланная. Выдает ошибку
fatal error C1189: #error : You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
P.S. А как лучше вызывать С-шные модули питоном ?
Отредактировано (Июль 5, 2011 20:31:15)
Офлайн
boost::python. Заодно в boost/python/details/wrap_python.hpp посмотрите, как именно это делается. Вроде бы для VC нужно кучу файлов сначала включить.
Офлайн