[swig]import error:dynamic module does not define init function,该怎么处理
[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...
------解决方案--------------------
看看手册,有提到几个常见的错误...
------解决方案--------------------
------解决方案--------------------
Another possible error is the following:
> > > import example
Traceback (most recent call last):
File " <stdin> ", line 1, in ?
ImportError: dynamic module does not define init function (init_example)
> > >
This error is almost always caused when a bad name is given to the shared object file. For example, if you created a file example.so instead of _example.so you would get this error. Alternatively, this error could arise if the name of the module is inconsistent with the module name supplied with the %module directive. Double-check the interface to make sure the module name and the shared object filename match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module.
能否找到_Dlnd.dll文件?
最近在搞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...
- C/C++ code
//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); ..... };
- C/C++ code
//Source file (DownloaderEngine.cpp) CDownloaderEngine::CDownloaderEngine() { .... } CDownloaderEngine::~CDownloaderEngine() { .... } ....
- C/C++ code
//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"
------解决方案--------------------
看看手册,有提到几个常见的错误...
------解决方案--------------------
------解决方案--------------------
Another possible error is the following:
> > > import example
Traceback (most recent call last):
File " <stdin> ", line 1, in ?
ImportError: dynamic module does not define init function (init_example)
> > >
This error is almost always caused when a bad name is given to the shared object file. For example, if you created a file example.so instead of _example.so you would get this error. Alternatively, this error could arise if the name of the module is inconsistent with the module name supplied with the %module directive. Double-check the interface to make sure the module name and the shared object filename match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module.
能否找到_Dlnd.dll文件?