I have a function inside a dll that I would like to call from my C++ application. The dll is also made in C++ and has a def file which shows the functions present in the dll. I
There seems to be some confusion here. Adding a file to the linker input is for statically-linked libraries (.lib on Windows). With statically-linked libraries, the code is just copied into your program at compile time. Dynamically-linked libraries (.dll in Windows) reside in different files (the DLLs) and are loaded by your program when you run it. To access a function in a dll, there's two main methods:
Use dllimport, similarly to how you exported the functions with dllexport
Load the DLL using LoadLibrary, then get a pointer to your function with GetProcAddress. If you're using this method, another thing you should note is that you should likely use extern "C"
on functions you're exporting to avoid name mangling. If you're having issues finding the function with GetProcAddress
, you can use Dependency Walker to examine the function names inside the DLL - they may be modified slightly depending on the calling convention used.