News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Lib HID / HID API

Started by RKSJBeck, November 14, 2025, 11:57:39 PM

Previous topic - Next topic

RKSJBeck

I've been trying to use the latest HID API in both source files , I get a linker error, and a compiled DLL.  Obviously a good DLL would be the ticket, but I don't seem to able to get it to work either.  I'm really a noob when it comes to non-embedded code, so I know I'm missing something obvious.  I keep getting :
"POLINK: error: Unresolved external symbol '_hid_init@0' - referenced from 'C:\Users\James Beck\Documents\Pelles C Projects\LibHIDTest\output\main.obj'.
POLINK: fatal error: 1 unresolved external(s)."
Even though I have loaded the DLL and even put the "lib" file in the linker library list.
I have included the DLL and header files, can anyone get the thing to work?

TimoVJL

#1
Have to use __cdecl calling convention.

Also header modification may help
/* To be removed in v1.0 */
#ifndef HID_API_CALL
    #define HID_API_CALL /**< API call macro */
#endif
and define preprocessor symbol
HID_API_CALL=__cdeclor in source
#define HID_API_CALL __cdecl

HINT:
open import library with pope.exe or TLPEView to see import symbol
pFile    Data    Description    Value
000016FC    0008    Type    IMPORT_OBJECT_CODE
        Name Type    IMPORT_OBJECT_NAME_NO_PREFIX
        Symbol info:   
        Symbol Name    _hid_open
        Dll    hidapi.dll
        Name    hid_open
That _hid_open is cdecl symbol
May the source be with you

RKSJBeck

Thanks for the help TimoVJL!

I'll give it a go.
It does compile without errors or warnings, and it links.

Vortex

Converting the import library to the module definition file :

LIBRARY hidapi
EXPORTS
"hid_close"
"hid_enumerate"
"hid_error"
"hid_exit"
"hid_free_enumeration"
"hid_get_device_info"
"hid_get_feature_report"
"hid_get_indexed_string"
"hid_get_input_report"
"hid_get_manufacturer_string"
"hid_get_product_string"
"hid_get_report_descriptor"
"hid_get_serial_number_string"
"hid_init"
"hid_open"
"hid_open_path"
"hid_read"
"hid_read_error"
"hid_read_timeout"
"hid_send_feature_report"
"hid_send_output_report"
"hid_set_nonblocking"
"hid_version"
"hid_version_str"
"hid_winapi_descriptor_reconstruct_pp_data"
"hid_winapi_get_container_id"
"hid_winapi_set_write_timeout"
"hid_write"

All the functions are following the __cdecl calling convention.
Code it... That's all...