使用Qt导入制造商的dll来控制电机控制器硬件时出错

时间:2014-07-21 18:23:14

标签: c++ qt dll header

我试图在我的Windows 7 64位计算机上使用Qt 5.3.1来访问第三方制造商提供的库,用于控制包含.DLL,标题的Performax步进控制器PMX-4EX-SA-TB9和lib文件。我在Visual C ++ studio中编写了一个命令提示程序,它连接得很好,但现在我想重写所有内容并使用Qt来制作一个更好看的程序。我的界面工作正常,我还没有编写任何专门使用该库的代码,我到目前为止只编写了所有按钮魔法,现在我想让它运行起来。

我的专业档案如下:

INCLUDEPATH += E:\qtTesting\ArcusTestInterface
QT          += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET   = ArcusTestInterface
TEMPLATE = app
SOURCES  += main.cpp\
            mainwindow.cpp
HEADERS  += mainwindow.h\
         += PerformaxCom.h
LIBS     += -LE:\qtTesting\ArcusTestInterface -lPerformaxCom
FORMS    += mainwindow.ui

我的lib,header和dll文件都与其他所有文件夹在同一个文件夹中,我还将DLL的副本放在调试文件夹中,试图使其工作正常。 QtCreator自动将头文件引入项目文件夹结构资源管理器,我可以双击该文件,看看我的构建问题在哪里。

这是头文件的副本

#ifdef PERFORMAXCOM_EXPORTS
#define PERFORMAXCOM_API __declspec(dllexport)
#else
#define PERFORMAXCOM_API __declspec(dllimport)
#endif

extern PERFORMAXCOM_API int nPerformaxCom;

#ifdef __cplusplus
extern "C" {
#endif

PERFORMAXCOM_API int fnPerformaxCom(void);

//USB reset

BOOL PERFORMAXCOM_API _stdcall fnPerformaxComUSBReset(IN HANDLE pHandle);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComFlush(IN HANDLE pHandle);

BOOL PERFORMAXCOM_API _stdcall fnPerformaxComGetNumDevices(OUT LPDWORD lpNumDevices);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComGetProductString(IN DWORD dwNumDevices, OUT LPVOID lpDeviceString, IN DWORD dwOptions);    
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComOpen(IN DWORD dwDeviceNum, OUT HANDLE* pHandle);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComClose(IN HANDLE pHandle);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetTimeouts(IN DWORD dwReadTimeout, DWORD dwWriteTimeout);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSendRecv(IN HANDLE pHandle, IN LPVOID wBuffer, IN DWORD dwNumBytesToWrite,IN DWORD dwNumBytesToRead,OUT LPVOID rBuffer);

signed int PERFORMAXCOM_API _stdcall fnPerformaxMove(IN HANDLE pHandle, 
                                                    IN int commandCode, 
                                                    IN int axes,
                                                    IN int moveDir,
                                                    IN long *value,
                                                    IN int modelCode);

signed int PERFORMAXCOM_API _stdcall fnPerformaxCommandReply(IN HANDLE pHandle, 
                                                             IN char *command, 
                                                             IN char *reply);

signed int PERFORMAXCOM_API _stdcall fnPerformaxIO(IN HANDLE pHandle, 
                                                    IN int commandCode, 
                                                    IN int bitNumber,
                                                    IN long *value,
                                                    IN int modelCode);

signed int PERFORMAXCOM_API _stdcall fnPerformaxMotorStat(IN HANDLE pHandle, 
                                                    IN int commandCode, 
                                                    IN int axes,
                                                    IN long *value,
                                                    IN int modelCode);

signed int PERFORMAXCOM_API _stdcall fnPerformaxSpeedAccel(IN HANDLE pHandle, 
                                                           IN int commandCode, 
                                                           IN int axes,
                                                           IN long *value,
                                                           IN int modelCode);

signed int PERFORMAXCOM_API _stdcall fnPerformaxGeneral(IN HANDLE pHandle, 
                                                        IN int commandCode, 
                                                        IN int axes,
                                                        IN long *value,  
                                                        IN int modelCode);


long PERFORMAXCOM_API _stdcall fnPerformaxComGetAxisStatus(IN HANDLE pHandle,DWORD dwAxisNumber);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetPulseSpeed(IN HANDLE pHandle,DWORD dwAxisNumber);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetPulsePos(IN HANDLE pHandle,DWORD dwAxisNumber);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetPulsePos(IN HANDLE pHandle,DWORD dwAxisNumber, DWORD pos);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetEncoderPos(IN HANDLE pHandle,DWORD dwAxisNumber);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetEncoderPos(IN HANDLE pHandle,DWORD dwAxisNumber, DWORD pos);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetPolarity(IN HANDLE pHandle,DWORD dwAxisNumber,DWORD dwPolarity);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetPolarity(IN HANDLE pHandle,DWORD dwAxisNumber);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetDIOSetup(IN HANDLE pHandle);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetDIOSetup(IN HANDLE pHandle, DWORD dio_setup);
long PERFORMAXCOM_API _stdcall fnPerformaxComGetDIO(IN HANDLE pHandle);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComGetDIOBit(IN HANDLE pHandle,DWORD bitn);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetDIO(IN HANDLE pHandle,DWORD dio_value );
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComSetDIOBit(IN HANDLE pHandle,DWORD bitn,DWORD bitv );
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComDoHome(IN HANDLE pHandle,
                                                           DWORD axis,
                                                           DWORD dir,
                                                           DWORD low_speed,
                                                           DWORD high_speed,
                                                           DWORD accel_time,
                                                           DWORD decel_time,
                                                           DWORD search_mode,
                                                           DWORD ramp_mode);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComDoMove(IN HANDLE pHandle,
                                                           DWORD axisn,
                                                           DWORD target,
                                                           DWORD low_speed,
                                                           DWORD high_speed,
                                                           DWORD accel_time,
                                                           DWORD decel_time);
BOOL PERFORMAXCOM_API _stdcall fnPerformaxComStop(IN HANDLE pHandle,
                                                           DWORD axisn,
                                                           DWORD ramp_stop);






#ifdef __cplusplus
}
#endif

在第38行构建期间出现错误,第一行像BOOL PERFORMAXCOM_API一样启动:语法错误:' int'之前应该是&#39 ;;'和缺少的类型说明符 - 假定的int和' IN' :未声明的标识符和' fnPerformaxComUSBReset' :不允许定义dllimport数据。 请帮我。我的界面都经过精心设计,我正在阅读以开始编码,而我却无法克服这个小小的障碍。 以下是错误的屏幕截图: Error Screen Shot

谢谢!

0 个答案:

没有答案