简体   繁体   English

链接器找不到导入的DLL的LIB文件

[英]Linker can't find LIB file of the DLL imported

I've looked through full 14 pages list of similar problems but didn't find my case. 我浏览了整整14页的类似问题列表,但没有找到我的案子。

I have VS2017 c++ solution which has two projects DLL and EXE. 我有VS2017 c ++解决方案,其中有两个项目DLL和EXE。 EXE projects includes DLL header to import function from it. EXE项目包括DLL标头,用于从中导入功能。

The problem is that linker can't find dllproject.lib file. 问题是链接器找不到dllproject.lib文件。 I tried to add it to Linker -> Input -> Additional Dependencies but didn't help because linker failed to find that lib file and it exists in the output folder. 我试图将其添加到Linker -> Input -> Additional Dependencies但没有帮助,因为链接器无法找到该lib文件,并且它存在于输出文件夹中。

Then I used 然后我用

#pragma comment( lib, "C:\\FULL_PATH\\dllproject.lib")

And this time helped. 这一次有所帮助。 But the problem is my local absolute path to the lib. 但是问题是我到lib的本地绝对路径。 I suppose I can somehow configure that in the project settings, but all my attempts failed. 我想我可以在项目设置中以某种方式进行配置,但是所有尝试都失败了。

In the DLL header file I have the block (was advised in other answers). 在DLL头文件中,我有块(在其他答案中建议)。

#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif

Please help. 请帮忙。

Adding a library to your project is a two step process. 向项目中添加库是一个两步过程。

You add the library name to Linker/Input/Additional Dependencies and you add the library folder to Linker/General/Additional Library Directories. 您将库名称添加到链接器/输入/其他依赖项,并将库文件夹添加到链接器/常规/其他库目录。

Then of course you have the potential problem of your program failing to find your DLL, but that's another question. 那么,您当然会遇到程序无法找到DLL的潜在问题,但这是另一个问题。

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

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