Share via


How do I link a dll to a C++ project in Visual Studio 2019

Question

Tuesday, March 17, 2020 6:04 AM

I'm building a project, included the dll's path in Project->Properties->Configuration Properties->Executable Directories. however, the program still complains that it cannot find the dll. Could someone please help? I am using Visual Studio Community Edition. thank you!

All replies (6)

Tuesday, March 17, 2020 10:06 AM ✅Answered | 1 vote

Try copying manually the DLL file to the output folder (where your .EXE file is generated). If this helps, it is possible to automate this operation.


Tuesday, March 17, 2020 1:31 PM ✅Answered | 1 vote

You should read the documentation that describes the search order that Windows uses when attempting to load a dll.

/en-us/windows/win32/dlls/dynamic-link-library-search-order


Wednesday, March 18, 2020 5:19 AM ✅Answered

Thanks a lot Anna!


Tuesday, March 17, 2020 9:35 AM | 1 vote

Hi LearnCPP,

Welcome to MSDN forum.

According to your description, please refer to the following guide: /en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=vs-2019

If you want to add the DLL header to your include path**,** please add it under Property Pages > Configuration Properties > C/C++ > General > Additional Include Directories.

If you want to add the DLL import library to your project, please add it under Property Pages > Configuration Properties > Linker.

If I misunderstand, please feel free to let me know.

Hope it helps and any feedback will be expected.

Best Regards,

Anna

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Wednesday, March 18, 2020 5:20 AM

Thanks a lot Viorel!


Wednesday, March 18, 2020 5:21 AM

Thanks a lot RLWA32!