Maxpm
Maxpm

Reputation: 25551

Simple Way to Use a DLL

I followed the MSDN walkthrough on creating and using a DLL in Visual C++ Studio, but it requires the user to add the DLL project to the same solution as the project they're working on.

Is there a simple way to include a DLL? Ideally, I'd like to just distribute my .dll (and the .lib, I suppose) to my friends so they can use it in their own projects.

I realize there are other walkthroughs out there (some of them on SO), but they all require editing the PATH environment variable, etc. Is that really the simplest way?

Upvotes: 1

Views: 196

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 992707

At a minimum, you need to do the following:

  • Include the .lib file in the project
  • Tell the linker where you put the .lib file (library search path)
  • Make the .dll file available at runtime (easiest is to put it in the same directory as the .exe)

To distribute the compiled .dll to your friends, you will need to include:

  • the .h file(s) for the compiler
  • the .lib file for the linker
  • the .dll file for runtime

Upvotes: 4

Related Questions