-2

I'm working with an Mcp2221, a chip for USB to I2C.

On the Microchip website is a dll to work with the Mcp2221 https://www.microchip.com/wwwproducts/en/MCP2221 I have downloaded the "MCP2221 DLL (v2.2.1)"

In the downloaded zip under unmanaged => lib I copied the mcp2221_dll_um_x64.lib to the directory D:\createJNIDll

MCP2221 DLL (v2.2.1)\unmanaged\lib\ content:

Zip Content

D:\createJNIDll\ content:

enter image description here

Now I working with Code::Blocks.
I created a new Project and in this Project a file named "main.cpp"

Under Settings => Compiler => Search directories I have added "D:\createJNIDll\" to Compiler and Linker.

Under Rightclick on my Project => Build options => Linker settings I have added "D:\createJNIDll\mcp2221_dll_um_x64.lib"

My main.cpp looks like this:

#include "mcp2221_dll_um.h"
#include <iostream>

int main(){
    wchar_t* res;
    int i = Mcp2221_GetLibraryVersion(res);
    std::cout << i << ": " << res << std::endl;
}

When I try to build and run the Project I get the Error:

fatal error: mcp2221_dll_um.h: No such file or directory

In the lib directory is a mcp2221_dll_um.h file as you can see in the picture above. So I expected that this header is in the .lib but I'm not 100% sure.

Can anybody help me to fix this problem that I can use the .lib in my project?

Morchul
  • 1,987
  • 1
  • 7
  • 21

1 Answers1

0

So I expected that this header is in the .lib but I'm not 100% sure

What gave you that idea?

The header is a file on disk. You've pointed the linker to the .lib file, but the compiler has no idea where to look for the header. Add that location to your include directories.

Bartek Banachewicz
  • 38,596
  • 7
  • 91
  • 135
  • I added the Header to the location of the .lib and now it compiles, Thanks. I think I have a little bit of misunderstanding lib files. My next problem is that I can't call any functions. I get "undefined reference to `_imp__Mcp2221_GetLibraryVersion@4' – Morchul Jan 09 '19 at 09:59
  • @Morchul [Here you go](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix). – Bartek Banachewicz Jan 09 '19 at 10:01