简体   繁体   English

在 .lib 中找不到头文件

[英]Can't find header file in .lib

I'm working with an Mcp2221, a chip for USB to I2C.我正在使用 Mcp2221,这是一种用于 USB 到 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)"在 Microchip 网站上有一个与 Mcp2221 一起使用的 dll https://www.microchip.com/wwwproducts/en/MCP2221我已经下载了“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在 unmanaged => lib 下下载的 zip 我将 mcp2221_dll_um_x64.lib 复制到目录 D:\\createJNIDll

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

邮编内容

D:\\createJNIDll\\ content: D:\\createJNIDll\\ 内容:

在此处输入图片说明

Now I working with Code::Blocks.现在我使用 Code::Blocks。
I created a new Project and in this Project a file named "main.cpp"我创建了一个新项目,在这个项目中创建了一个名为“main.cpp”的文件

Under Settings => Compiler => Search directories I have added "D:\\createJNIDll\\" to Compiler and Linker.在设置 => 编译器 => 搜索目录下,我已将“D:\\createJNIDll\\”添加到编译器和链接器。

Under Rightclick on my Project => Build options => Linker settings I have added "D:\\createJNIDll\\mcp2221_dll_um_x64.lib"在我的项目上右键单击 => 构建选项 => 链接器设置,我添加了“D:\\createJNIDll\\mcp2221_dll_um_x64.lib”

My main.cpp looks like this:我的 main.cpp 看起来像这样:

#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致命错误:mcp2221_dll_um.h:没有那个文件或目录

In the lib directory is a mcp2221_dll_um.h file as you can see in the picture above.在 lib 目录中有一个 mcp2221_dll_um.h 文件,如上图所示。 So I expected that this header is in the .lib but I'm not 100% sure.所以我希望这个头文件在 .lib 中,但我不是 100% 确定。

Can anybody help me to fix this problem that I can use the .lib in my project?任何人都可以帮助我解决这个问题,我可以在我的项目中使用 .lib 吗?

So I expected that this header is in the .lib but I'm not 100% sure所以我希望这个头文件在 .lib 中,但我不是 100% 确定

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.您已将链接器指向.lib文件,但编译器不知道在哪里查找头文件。 Add that location to your include directories.将该位置添加到您的包含目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM