0

I build the hidapi on windows using Visual Studios. The build generated a 'hidapi.lib' file. Now I am trying to write C code using Eclipse IDE and have included the 'hidapi.lib' by changing it's name to 'libhid.lib'. The hidapi.h is also present and included. The error comes when I try to access any of the functions of the hidapi.h The compiler gives an undefined reference error everytime I run the program. Where am Igoing wrong ?

source code
compiler error

/* ============================================================‌​
Name : hid_attemp1.c 
Author : Shantanu 
Version : 
Copyright : Your copyright notice 
Description : Hello World in C, Ansi-style 
============================================================‌​===*/ 
#ifdef WIN32 
#include <windows.h> 
#endif 
#include <stdio.h> 
#include <stdlib.h> 
#include "hidapi.h" 
int main(void) { 
    int r; 
    r = hid_init(); 
    if(r<0) 
        printf("error in init()\n"); 
    return EXIT_SUCCESS; 
}
AgataB
  • 647
  • 2
  • 10
  • 18
the_mamba
  • 119
  • 1
  • 2
  • 10
  • Can you paste code into your answer, rather than including screenshots, please? – AgataB Sep 01 '16 at 08:43
  • Mixing binaries from GCC and MSVC sometimes does not work, especially in the case of static libraries. Can you compile both HIDAPI and your program using a single toolchain? – David Grayson Sep 01 '16 at 17:58
  • The hidapi repository I downloaded from Github contains a .sln project which can be build using only MS VS. – the_mamba Sep 02 '16 at 04:54
  • https://github.com/signal11/hidapi - this is the Git repository I am using – the_mamba Sep 02 '16 at 04:54

1 Answers1

0

I tried creating a C project on visual studio, included the hidapi.h and linked the hidapi.lib to the project. The project build successfully and I was able to run it. As far as I am concerned, the problem is the incompatibility of the 'hidapi.lib' between the Visual Studio and Eclipse IDE.

the_mamba
  • 119
  • 1
  • 2
  • 10