Approach to solving LNK2019s?  
Author Message
M Minasi





PostPosted: Visual C++ Express Edition, Approach to solving LNK2019s? Top

Hi --

I took some MSDN code and tried to make it work but, as it often the case, I got an LNK2019 error. Now, judging from the other ones that I've gotten, the answer is to

1) add a pragma pointing to a .lib file, and

2) make sure that the LIB environment variable includes whatever folder the .lib file is in.

(I'm doing command-line compiles of console, non-CLR apps.)

Simply adding Advapi32.lib to the top of my apps has solved the problem in general, but I'm trying to run an MSDN code sample at http://www.hide-link.com/ that seems to compile fine, but I get the LKN2019.

My question is, how should I attack this Given an error like this, how would I find the .lib file (clearly it's in the SDK somewhere, but there are LOT of files there) that the program needs

Thanks!



Visual Studio Express Editions40  
 
 
M Minasi





PostPosted: Visual C++ Express Edition, Approach to solving LNK2019s? Top

Solved it. For those ever dealing with this:

1) The part I forgot to mention above is that when calling a Win32 API, look at the MSDN documentation on the particular API you're calling. The library will be named there. Typically you've got to do two things:

a) add an .h file up top in your program, as in

#include <somestuff.h>

The particular .h file will be referenced in the MSDN docs.

b) add a comment to the linker to tell it where to find the actual code. It goes up top also:

#pragma comment (lib, "advapi32.lib")

2) I had already done those things before I posted... but a closer look showed that I'd created the problem myself! I'd created a function with a long name, and when I invoked it, I dropped a character. Stupid!