swig
/* File: copy2.i */
%module copy2
%{
#define SWIG_FILE_WITH_INIT
#define _CRT_SECURE_NO_WARNINGS
#include "copy2.h"
%}
int file_copy(const wchar_t* srcPath, const wchar_t* dstPath);
long long getcopysize();
int setcopysize();
swig -c++ -python .\copy2.i
"""
setup.py
"""
from distutils.core import setup, Extension
copy2_module = Extension('_copy2',
sources=['copy2_wrap.cxx', 'copy2.cpp'],
)
setup (name = 'copy2',
version = '0.1',
author = "SWIG Docs",
description = """Simple swig example from docs""",
ext_modules = [copy2_module],
py_modules = ["copy2"],
)
-
python setup.py build
-
c++类
#ifndef FOO_H__
#define FOO_H__
class Foo
{
public:
Foo();
int GetNum();
void SetNum(int num);
private:
int m_num;
};
#endif // FO
#include "Foo.h"
Foo::Foo()
: m_num(-1)
{
}
int Foo::GetNum()
{
return m_num;
}
void Foo::SetNum( int num )
{
m_num = num;
}
/* File: foo.i */
%module foo
%{
#include "Foo.h"
%}
class Foo
{
public:
Foo();
int GetNum();
void SetNum(int num);
private:
int m_num;
};
Unable to find vcvarsall.bat 错误的解决
增加系统变量
VS90COMNTOOLS
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\