Good morning, can somebody please help me.. I am desperate.
I created a basic example to migrate a C++ class to python. I have successfully converted from C++ -> JAVA but now I need it in Python. I do it in Visual Studio 2010 on Windows 8, (and tried on Windows 7 32bit too). Everything works, .py was generated and .pyd was generated too, but when i run the python program it crashes. It writes program stop working (classic windows window). I found it crash just right on library load. It is this line:
_mod = imp.load_module('_KatanaWrapper', fp, pathname, description)
But this whole file is generated from SWIG so i don't think there is something wrong. It must be something with SWIG? Does anyone know?
I do it in a similar way as here description
Edit 2x: This is my c++ code. There is all right...its so simple and it works in c++.
Test.h
#pragma once
class Test
{
public:
Test(void);
~Test(void);
int mySum(int first, int second);
};
Test.c
#include "Test.h"
Test::Test(void)
{
}
int Test::mySum(int first,int second) {
return first + second;
}
Test::~Test(void)
{
}
Edit: And here is my interface file (nothing special):
/* File : translate.i */
%module KatanaWrapper
%{
/* Includes the header in the wrapper code */
#include "Test.h"
%}
/* Parse the header file to generate wrappers */
%include "Test.h"
And command line of this:
$(SolutionDir)\..\swig\swig.exe -c++ -python %(FullPath)
Edit: and interesting is, when I change this command to
$(SolutionDir)\..\swig\swig.exe -c++ -java %(FullPath)
It i must write to generated classes package (package testapplication;) but it still don't works (java crashes) but when i change command like this:
$(SolutionDir)\..\swig\swig.exe -c++ -java -package testapplication %(FullPath)
It works! Is something similar in PYTHON? Can help this?
This is compiler options generated by VS. It's little bit chaos and there is Java includes too (for Java migration)
/I"C:\Program Files (x86)\Java\jdk1.7.0_17\include\win32" /I"C:\Program Files (x86)\Java\jdk1.7.0_17\include" /I"C:\Python27\include" /I"C:\Python33\include" /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "KATANAWRAPPER_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\_KatanaWrapper.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue