Re: Trouble linking library

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/20/05


Date: Sun, 20 Feb 2005 00:07:39 -0500

Hmm. The last time I looked, LNK2001 was not an error message. There is an error message
that starts with this code, BUT IT HAS LOTS OF TEXT THAT FOLLOWS IT! If you want help, you
have to make a bug report that contains all the information you have available. For
example, what is the name of the symbol it cannot find?

You have not described what you mean by a console application. For example, is it a .c or
a .cpp source file? A console application could be either one, but you have not said
anything that gives us a context for analyzing the problem.

All you've given is a vague and fairly useless description of the problem.

Note: if the DLL was compiled as C source, it will have a function, for example,
        int SomeFunction(int x);
but if you include the header file in C++, it will want to link to a function called
        SomeFunction$67AIEGHQ@4
or some equally silly name. Had you included the text of the error message, instead of
something as completely useless as the error number, something might be inferred.

I have no idea why people will give compiler or linker error numbers without the
accompanying text; the text is the ONLY important part of the message. Instead, we always
get the least useful and least important part of the message in reports.

I suspect that your header file is missing the following declaration:

#ifdef __cplusplus
extern "C" {
#endif
.... function declarations here
#ifdef __cplusplus
}
#endif

If you do not have these in your header file, and the DLL was compiled for a C interface,
this would explain the error. But without any meaningful bug report, this is just a guess.
                                joe
On Fri, 18 Feb 2005 02:33:01 -0800, Dennis Aries <DennisAries@discussions.microsoft.com>
wrote:

>I have a third-party dll, together with the given header-file and lib-file.
>When I include /link the files in a console-application, everything works
>fine. When I try to do the same in an MFC-application, I get the
>LNK2001-error.
>
>In my projectbrowser, I can see the defined structures (from that
>header-file), but not the functions in that same file (which I would expect
>to see under globals).
>
>Any suggestions on how to solve this problem?

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Xmkmf/make problem
    ... > I have several Xlib programs that compiled successfully on earlier ... > get an error message: ... > It looks as though this header file, and several others, have been moved ... the best option is to fix the broken programs. ...
    (freebsd-questions)
  • Re: Newbie question: Need for header file when linking to static library
    ... advice on an error message, it is absolutely critical that you copy the error message *IN ... either you have failed to include the proper header file during the build process, ... SOMENAME void OtherFunction; ...
    (microsoft.public.vc.mfc)
  • Re: GetLocalPathName could not be located in Kernel32.dll
    ... >following error message: The procedure entry point ... If you do not have this header file, ... >obtained by downloading the most recent SDK from the SDK Update Site." ... >But now I am getting the following error during compilation: ...
    (microsoft.public.dotnet.languages.vc)
  • C++ programming question
    ... The examples in the book use the header file iostream.h (#include ... When I compile the programs, I get an error message ... and where are the "modern" header files that support these functions? ...
    (alt.os.linux)
  • Re: Trouble linking library
    ... If this is the way posts are replied to here, ... > I have no idea why people will give compiler or linker error numbers without the ... > If you do not have these in your header file, and the DLL was compiled for a C interface, ... But without any meaningful bug report, ...
    (microsoft.public.vc.mfc)