简体   繁体   中英

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.

I have VS2017 c++ solution which has two projects DLL and EXE. EXE projects includes DLL header to import function from it.

The problem is that linker can't find dllproject.lib file. 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.

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. 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).

#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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