I am trying to compile a DLL in VC++ 2010 command prompt, and one of the functions I am using is in urlmon.dll. How do I link this DLL to my source file? (It's only one .cpp file). I tried putting the dll in the same folder. Do I need the lib file instead?
Currently I'm just ru开发者_StackOverflownning: cl -LD filename
I've tried googling, but I have had no success. Thanks for those who looked.
You must link with the import library urlmon.lib. It's impossible to link directly to a DLL. (The only other way to get functions out of a DLL, in the absence of an "import library" for that DLL, is to use functions like LoadLibrary and GetProcAddress to find, load, and extract the particular function you want.)
Put this line into your source file:
#pragma comment(lib, "urlmon")
Your source file already is using the urlmon functions, so it makes sense to list the library right alongside.
精彩评论