C 中调用DLL的有关问题 undefined reference to 'InitSMGPAPI’
C 中调用DLL的问题 undefined reference to 'InitSMGPAPI’
程序源码 :
#include <stdio.h>
#include "smgpapi.h "
#include "smgpdef.h "
#define RECV_MSG_TIME_OUT 2 /* Seconds */
static DeliverResp g_DeliverResp;
int main(void)
{
/* Local Vars */
int nRetCode;
/* Call API InitSMGPAPI*/
/* If Your Config File Not In Current Dir Or Config Dir Please */
/* All Dir And File Name */
nRetCode = InitSMGPAPI(NULL);
if(nRetCode)
{
printf( "InitSMGPAPI Return Error\n ");
}
/* Call SMGPDeliver To Get Message */
nRetCode = SMGPDeliver((int)RECV_MSG_TIME_OUT,&g_DeliverResp);
if(nRetCode)
{
printf( "Recv Msg From SMGW Fail!\n ");
}
else
{
printf( "Recv Msg From SMGW Success!\n ");
}
return 0;
}
涉及到的头文件及 DLL文件都在同一目录下。
smgpapi.h 如下:
#ifndef _SMGP_API_H_
#define _SMGP_API_H_
/*#define SMGP_CLIENT_VERSION10*/
#ifdef SMGP_API_EXPORTS
#define SMGPAPI_EXPORTS int __stdcall
#else
#define SMGPAPI_EXPORTS int
#endif
#ifdef _WIN32
#pragma pack(push,1)
#elif defined _AIX
#pragma options align=packed
#elif defined _HPUX
#pragma pack 1
#else
#pragma pack (1)
#endif
/* Send Batch Message Responce Which Is Written In File */
typedef struct
{
char sMsgID[10+1];
int nErrorCode;
char sPhoneNo[21+1];
}SendBatchResp;
/* Query Message Responce Struct */
typedef struct
{
int nMT_TLMsg;
int nMT_TLusr;
int nMT_Scs;
int nMT_WT;
int nMT_FL;
int nMO_Scs;
int nMO_WT;
int nMO_FL;
}QueryResp;
/* Receive Message Responce Struct */
#ifdef SMGP_API_EXPORTS
/*DLL VERSION*/
typedef struct
{
unsigned int nIsReport;
unsigned int nMsgFormat;
unsigned int nMsgLength;
char sMsgID[10+1];
char sRecvTime[14+1];
char sSrcTermID[21+1];
char sDestTermID[21+1];
char sMsgContent[252+1];
char sReserve[8+1];
}DeliverResp;
typedef struct
{
unsigned int nSerialNo; /*消息头中的流水号*/
unsigned int nStatus;
unsigned int nMsgType;
unsigned int nMsgFormat;
unsigned int nDesMode;
unsigned int nKeySerialNo;
unsigned int nIIType;
unsigned int nMsgLength;
char sMsgID[20+1];
char sSrcTermID[21+1];
char sDestTermID[21+1];
char sSessionID[20+1];
程序源码 :
#include <stdio.h>
#include "smgpapi.h "
#include "smgpdef.h "
#define RECV_MSG_TIME_OUT 2 /* Seconds */
static DeliverResp g_DeliverResp;
int main(void)
{
/* Local Vars */
int nRetCode;
/* Call API InitSMGPAPI*/
/* If Your Config File Not In Current Dir Or Config Dir Please */
/* All Dir And File Name */
nRetCode = InitSMGPAPI(NULL);
if(nRetCode)
{
printf( "InitSMGPAPI Return Error\n ");
}
/* Call SMGPDeliver To Get Message */
nRetCode = SMGPDeliver((int)RECV_MSG_TIME_OUT,&g_DeliverResp);
if(nRetCode)
{
printf( "Recv Msg From SMGW Fail!\n ");
}
else
{
printf( "Recv Msg From SMGW Success!\n ");
}
return 0;
}
涉及到的头文件及 DLL文件都在同一目录下。
smgpapi.h 如下:
#ifndef _SMGP_API_H_
#define _SMGP_API_H_
/*#define SMGP_CLIENT_VERSION10*/
#ifdef SMGP_API_EXPORTS
#define SMGPAPI_EXPORTS int __stdcall
#else
#define SMGPAPI_EXPORTS int
#endif
#ifdef _WIN32
#pragma pack(push,1)
#elif defined _AIX
#pragma options align=packed
#elif defined _HPUX
#pragma pack 1
#else
#pragma pack (1)
#endif
/* Send Batch Message Responce Which Is Written In File */
typedef struct
{
char sMsgID[10+1];
int nErrorCode;
char sPhoneNo[21+1];
}SendBatchResp;
/* Query Message Responce Struct */
typedef struct
{
int nMT_TLMsg;
int nMT_TLusr;
int nMT_Scs;
int nMT_WT;
int nMT_FL;
int nMO_Scs;
int nMO_WT;
int nMO_FL;
}QueryResp;
/* Receive Message Responce Struct */
#ifdef SMGP_API_EXPORTS
/*DLL VERSION*/
typedef struct
{
unsigned int nIsReport;
unsigned int nMsgFormat;
unsigned int nMsgLength;
char sMsgID[10+1];
char sRecvTime[14+1];
char sSrcTermID[21+1];
char sDestTermID[21+1];
char sMsgContent[252+1];
char sReserve[8+1];
}DeliverResp;
typedef struct
{
unsigned int nSerialNo; /*消息头中的流水号*/
unsigned int nStatus;
unsigned int nMsgType;
unsigned int nMsgFormat;
unsigned int nDesMode;
unsigned int nKeySerialNo;
unsigned int nIIType;
unsigned int nMsgLength;
char sMsgID[20+1];
char sSrcTermID[21+1];
char sDestTermID[21+1];
char sSessionID[20+1];