[英]Why am I getting an Unresolved External Symbol error while the typedef is present?
[英]Why am I getting an “unresolved external symbol” message?
我試圖使用IBM的EHLLAPI與他們的Personal Communicator終端仿真器連接。 我已經從這個頁面復制了他們的示例代碼,但是當我嘗試構建它時它給了我一個錯誤。
1>------ Build started: Project: PCOMAPI, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol _hllapi@16 referenced in function _main
1>C:\Users\[username]\Documents\Visual Studio 2013\Projects\VPARSAPI\Debug\PCOMAPI.exe : fatal error LNK1120: 1 unresolved externals
我不完全確定_hllapi @ 16是什么,我在代碼中沒有看到它。 自從我使用C ++以來已經有一段時間了,所以它可能是我想念的簡單事情。 代碼如下:
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include "hapi_c.h"
int main(char **argv, int argc) {
int HFunc, HLen, HRc;
char HBuff[1];
struct HLDConnectPS ConnBuff;
// Send Key string for HOME+string+ENTER:
char SendString[] = "@0Hello World!@E";
HFunc = HA_RESET_SYSTEM;
HLen = 0;
HRc = 0;
hllapi(&HFunc, HBuff, &HLen, &HRc);
if (HRc != HARC_SUCCESS) {
printf("Unable to access EHLLAPI.\n");
return 1;
}
HFunc = HA_CONNECT_PS;
HLen = sizeof(ConnBuff);
HRc = 0;
memset(&ConnBuff, 0x00, sizeof(ConnBuff));
ConnBuff.stps_shortname = 'A';
hllapi(&HFunc, (char *)&ConnBuff, &HLen, &HRc);
switch (HRc) {
case HARC_SUCCESS:
case HARC_BUSY:
case HARC_LOCKED: // All these are OK
break;
case HARC_INVALID_PS:
printf("Host session A does not exist.\n");
return 1;
case HARC_UNAVAILABLE:
printf("Host session A is in use by another EHLLAPI application.\n");
return 1;
case HARC_SYSTEM_ERROR:
printf("System error connecting to session A.\n");
return 1;
default:
printf("Error connecting to session A.\n");
return 1;
}
HFunc = HA_SENDKEY;
HLen = strlen(SendString);
HRc = 0;
hllapi(&HFunc, SendString, &HLen, &HRc);
switch (HRc) {
case HARC_SUCCESS:
break;
case HARC_BUSY:
case HARC_LOCKED:
printf("Send failed, host session locked or busy.\n");
break;
default:
printf("Send failed.\n");
break;
}
HFunc = HA_DISCONNECT_PS;
HLen = 0;
HRc = 0;
hllapi(&HFunc, HBuff, &HLen, &HRc);
printf("EHLLAPI program ended.\n");
return 0;
}
我的鏈接器標志是:
這是一個鏈接器錯誤。 您需要將鏈接傳遞給EHLLAPI庫的.lib文件(導入庫)。
實際上,查看文檔時 ,該庫中有許多.lib文件。 您需要仔細研究文檔,找出您需要的文檔。
如編譯和鏈接部分所述,您必須包含用於靜態鏈接的pcscal32.lib ,因此可以解析* hapi_c.h *中的符號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.