Visual C++ Question

I decided to bite the bullet and learn to use Visual C++ (I’m an old *nix C programmer). Being impatient, I decided to leap ahead of where I am in my book and call some functions in a .dll that interfaces with the HW I am writing the program for.

I am including the supplied .h file but I am getting unresolved references when I build. How do I specify that the .dll should be referenced?

Unresolved references sounds like a linker error, not a compiler error. You need to make sure you’re including the proper libraries in the link step. This is from memory and also a little dependent on which version of VC you’re using, but you basically want to go to the project properties, build section, find the linker settings, and add additional library dependencies, specifying the .lib file that contains the functions you’re calling (the implementations actually reside in a dll but there is a .lib which gives you the actual entry points from your code’s point of view and you need to link to that).

The MSDN pages specify which libraries you need for various API functions. For example, the page for GetAdaptersAddresses says, “Link Library: Iphlpapi.lib” at the bottom, so that’s the library you’d add. Your DLL should have a similar .lib file that you can link to.

ETA: it might help to point out that the “additional library dependencies” is analogous to the “-l” arguments on most unix C compilers, and there is an “additional library directories” setting that is like the “-L” option in that it specifies additional directories to look in for those libraries.

That makes sense.

My apologies, not knowing how much you know, I’ll ask: Do you understand the difference between implicit and explicit linking?

Linking and executable to a dll

I do now :wink:

ntucker solved my problem. I just couldn’t figure out where to specify the .lib file. Why does MSFT make everything so complicated?