我是SWIG的新手,所以我完全沒有經驗,但我真的很想使用Riftek LASER的SDK(https://riftek.com/media/rit/SDK/RFDevice_SDK.zip)。SWIG一個SDK到Python
SDK本身包含一些頭文件,dll和def文件。我寫了下面的呷文件到現在爲止:
/* rfdevice.i */
%module rfdevice
%{
#include <windows.i>
#include <typemaps.i>
#include "include/RF625Device.h"
#include "include/RF625Device_Legacy.h"
#include "include/RFDevice.h"
#include "include/RFEthernetDetector.h"
#include "include/RFEthernetDevice.h"
#include "include/RFQDPMotorDevice.h"
#include "include/RFSerialDevice.h"
#include "include/RFString.h"
#include "include/RFTypeDefs.h"
#include "include/serial.h"
%}
%include <windows.i>
%include <typemaps.i>
%apply void *INPUT {void *lpResultBuffer};
%apply float *OUTPUT {float *lpPointsBuffer};
%apply USHORT *OUTPUT {USHORT *lpCount};
%include "include/RFString.h"
%include "include/serial.h"
namespace RFDevice {
%include "include/RFTypeDefs.h"
%include "include/RFEthernetDetector.h"
%include "include/RFDevice.h"
%include "include/RFEthernetDevice.h"
%include "include/RFQDPMotorDevice.h"
%include "include/RFSerialDevice.h"
%include "include/RF625Device_Legacy.h"
%include "include/RF625Device.h"
}
我可以產生rfdevice_wrap.c文件,但我不能編譯它,因爲我得到了很多的來自編譯器的未定義的引用。
我的問題是: - 我必須以某種方式將dll或def文件包含在i文件中嗎? - 是否有更快/更簡單的方式讓SDK能夠與Python協同工作?
我在Windows 7 64位下使用g ++編譯MinGW。
到目前爲止,我設法確定了我的真正問題。我根據當前狀態修改了問題。
有一個在頭一個下面的函數定義:
USHORT ConvertResultToPoints(void IN *lpResultBuffer, float OUT *lpPointsBuffer, USHORT OUT *lpCount, USHORT *lpMeasureCnt = NULL, USHORT *lpPacketCnt = NULL, BOOL bChecksumCheck = FALSE);
這裏的「IN」和「OUT」是造成了一些SWIG truble。我不斷收到以下編譯器錯誤:
include\RF625Device_Legacy.h(259): Error: Syntax error in input(3).
在自變量處理下的SWIG文檔中存在該問題的可能解決方案。我已經將它包含在i文件中,但我一直在收到編譯器錯誤。
你應該在這裏包含來自編譯器/鏈接器的錯誤消息,請參閱[mcve] –
爲什麼使用g ++編譯* .c文件? –
沒有辦法在i(接口)文件中包含dll/def文件,但編譯代碼時必須包含它們 –