0

I am attempting to use IBM's EHLLAPI to interface with their Personal Communicator Terminal Emulator. I have copied their sample code from this page, but it's giving me an error when I try to build it.

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

I'm not entirely certain what this _hllapi@16 is, and I'm not seeing it in the code. It has been a while since I've worked with C++, so it may be something simple I'm missing. The code is as follows:

#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;
}

My linker flags are:

  • /OUT:"C:\Users[username]\Documents\Visual Studio 2013\Projects\VPARSAPI\Debug\PCOMAPI.exe" /MANIFEST /NXCOMPAT
  • /PDB:"C:\Users[username]\Documents\Visual Studio
  • 2013\Projects\VPARSAPI\Debug\PCOMAPI.pdb" /DYNAMICBASE "kernel32.lib"
  • "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib"
  • "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib"
  • "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL
  • /PGD:"C:\Users[username]\Documents\Visual Studio2013\Projects\VPARSAPI\Debug\PCOMAPI.pgd" /SUBSYSTEM:CONSOLE
  • /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
  • /ManifestFile:"Debug\PCOMAPI.exe.intermediate.manifest"
  • /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
4
  • "unresolved external symbol" is always a linker error. What are your linker flags?
    – abiessu
    Nov 20, 2013 at 22:49
  • @abiessu I've edited my linker flags into the question... I think
    – SaintWacko
    Nov 20, 2013 at 22:57
  • _hllapi@16 is your hllapi function that is immediately visible in the code. But you never linked the actual definition of that function from anywhere. There must be some sort of HLLAPI library that you are supposed to use. I don't see anything that would look like HLLAPI library in your linker parameter list. Nov 20, 2013 at 23:01
  • I'm not familiar with EHLLAPI but I don't see any EHLLAPI libraries in the linker options. Shouldn't there be at least one? Nov 20, 2013 at 23:01

2 Answers 2

2

That is a linker error. You need to pass to the linker the .lib file, the import library, for the EHLLAPI library.

In fact, looking at the documentation, there are a host of .lib files with this library. You'll need to study the documentation carefully to work out which ones you need.

5
  • Ah, thank you! This got rid of that error, but now I'm getting 1>LINK : fatal error LNK1104: cannot open file 'EHLAPI32.lib'. I've added it to the Additional Dependencies field, and added its path to the Additional Library Directories field.
    – SaintWacko
    Nov 20, 2013 at 23:11
  • I guess that file cannot be found. Have you loaded up one of the samples to see how that is configured? Nov 20, 2013 at 23:12
  • Hm... If I add the full path to Additional Dependencies, it works. I'm guessing the Additional Library Directories field isn't what I think it is.
    – SaintWacko
    Nov 20, 2013 at 23:14
  • No, I think Additional Library Directories is what you think. Not sure why you are having problems. That's always how I do it. Nov 20, 2013 at 23:17
  • Hm. Okay, well, I'll look into it further, but in the meantime this works. Just used the API to send my first message to the terminal emulator! Thanks for your help.
    – SaintWacko
    Nov 20, 2013 at 23:21
0

As stated under the section Compiling and Linking you have to include pcscal32.lib for static linking, so the symbols in *hapi_c.h* can be resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.