[swig]import error:dynamic module does not define init function
最近在搞swig interface to python, 弄得頭很大...
弄了3天還是解決不了問題 只知道似乎跟少了init這function有關
想請問各位 遇到這種問題該怎麼解決
註: 編譯完後共會產生 py, cxx, pyd 以及lib檔
以下是我的部份程式碼 謝謝(環境vc2008, build Dll by empty project)
使用Python, 輸入import Dnld
會跳出 import error:dynamic module does not define init function...
//header file(DownloaderEngine.h)class __declspec(dllexport) CDownloaderEngine{public: CDownloaderEngine(); virtual ~CDownloaderEngine(); signed char OpenPort(signed char _ucPort, unsigned long _ulBaudRate, unsigned char _ucParity, unsigned char _ucStopBits,unsigned char _ucData); .....};
//Source file (DownloaderEngine.cpp)CDownloaderEngine::CDownloaderEngine(){ ....}CDownloaderEngine::~CDownloaderEngine(){ ....}....
//Downloader.i %module Dnld %include <windows.i> %include <std_vector.i> %include <std_map.i> %{ #define SWIG_FILE_WITH_INIT #include ".\SerialComm\DownloaderEngine.h" %} /* Parse the header file to generate wrappers */ %include ".\SerialComm\DownloaderEngine.h"