p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual C++ (http://p2p.wrox.com/forumdisplay.php?f=88)
-   -   Link Problems with"unresolved external symbols" (http://p2p.wrox.com/showthread.php?t=35226)

ConstantineAugustus November 17th, 2005 06:10 PM

Link Problems with"unresolved external symbols"
 
:(When I task built the program described in Chapter 2 of Introduction to Visual C++ 6.0 by Ivor Horton (Document X03-58736-0598), pp 64-65;71-72, I had several problems with the compilation.[xx(] I have 20 Lnk2001 error messages for various symbols. Most of the symbols, like __imp__DrawTextA@20 and __imp__DispatchMessageA@4 start with __imp__ as a prefix. Whee I look up each symbol after discarding the prefix, I am told that I have to import user32.lib. ;)

[?]THE QUESTION: How do I include this library? Describe, as best as you can, the button clicks that get me where I need to go so that I can fill in the blanks that fix things.[?]

[^]Thanks

Clayton E. Benignus

ConstantineAugustus November 17th, 2005 10:34 PM

OK, I was able to accidentally solve the problem on my own. To tell the truth, I get a little bit absent minded about these fixes, so I'm going to record this fix here in case it comes up again:

1) When you discover what libraries you need, put their headers at the beginning of the program.

[8]Example:
#include "stdafx.h"
#include "winuser.h"
#include "wingdi.h"
#include <ios.h>
#include <tchar.h>

2)Set the parameters:
     Project=>Settings=>General
     ;)In General, make sure the Microsoft Foundation Classes has
         the appropriate entry. In my case, it was "Use MFC in a
         shared DLL"

3) Project=>Settings=>Link
     ;)In Object/Library Modules, list the libraries. In may case,
     they were: user32.lib gdi32.lib .

That got rid of 98% of my compile problems. I am still having problems with:

MSVCRTD.lib(crtexe.obj):error LNK2001: unresolved external symbol _main

However, I got rid of most of the problems. I'll be researching this problem next.I may post on this later.

hariharan November 22nd, 2005 06:34 AM

In vc++ you can add libraries by,
  Project>settings>link>projectoption....type the name of the library you want to have.

If you want to add the library folder to your application,
 Tools>options>directories>show directories for(select library) then double click the empty entry to browse and add your library folder

Regards,
HARI R


All times are GMT -4. The time now is 07:48 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.