Solved

error Lnk2001: unresolved external symbol

Posted on 2003-10-29
15
209,257 Views
Last Modified: 2011-08-18
Hi,

I have a linking problem after attempting to build the file. The error is as follows:

glovenew.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall vhtIOConn::~vhtIOConn(void)" (??1vhtIOConn@@UAE@XZ)
glovenew.obj : error LNK2001: unresolved external symbol "public: double __thiscall vhtDevice::getLastUpdateTime(void)" (?getLastUpdateTime@vhtDevice@@QAENXZ)
glovenew.obj : error LNK2001: unresolved external symbol "public: __thiscall vhtTracker::vhtTracker(class vhtIOConn *,bool)" (??0vhtTracker@@QAE@PAVvhtIOConn@@_N@Z)
glovenew.obj : error LNK2001: unresolved external symbol "public: __thiscall vhtCyberGlove::vhtCyberGlove(class vhtIOConn *,bool)" (??0vhtCyberGlove@@QAE@PAVvhtIOConn@@_N@Z)
glovenew.obj : error LNK2001: unresolved external symbol "public: __thiscall vhtIOConn::vhtIOConn(char const *,char const *,char const *,char const *,char const *)" (??0vhtIOConn@@QAE@PBD0000@Z)
Debug/glovenew.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.


Could anyone tell me what is wrong and how to go about solving it? Thanks.
0
Comment
Question by:kvng
  • 6
  • 3
  • 2
  • +3
15 Comments
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 50 total points
ID: 9643138
You are using some classes (vhtIOConn, vhtDevice...) which are kept in some library. It is not enough to add h-file with these classes, you need to add also library file for linker. The way you do it depends on the compiler. For example, in VC++ you need to add library name to: Project - Settings - Link - Object/library modules.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9643159
If all these classes belong to your own project, this means that you didn't implement number of functions:

vhtIOConn::~vhtIOConn
vhtDevice::getLastUpdateTime
...

For example:

class a
{
    A();           // only declaration, no implementation
};

// client.cpp

...
A a;          // compiles, but produces linker error: A::A is not implemented
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9643169
You have to write code for the functions vhtIOConn::~vhtIOConn(void), vhtDevice::getLastUpdateTime(void), ...
0
 

Author Comment

by:kvng
ID: 9643369
After adding the appropriate library modules, i get the following errors:

msvcirt.lib(MSVCIRT.dll) : error LNK2005: "public: virtual __thiscall ios::~ios(void)" (??1ios@@UAE@XZ) already defined in libcid.lib(_ios.obj)
msvcirt.lib(MSVCIRT.dll) : error LNK2005: "public: class ostream & __thiscall ostream::operator<<(unsigned char)" (??6ostream@@QAEAAV0@E@Z) already defined in libcid.lib(ostrchar.obj)
msvcirt.lib(MSVCIRT.dll) : error LNK2005: "public: class ostream & __thiscall ostream::operator<<(char const *)" (??6ostream@@QAEAAV0@PBD@Z) already defined in libcid.lib(ostream.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strchr already defined in LIBCD.lib(strchr.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in LIBCD.lib(sprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fflush already defined in LIBCD.lib(fflush.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _getenv already defined in LIBCD.lib(getenv.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBCD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _realloc already defined in LIBCD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCD.lib(dbgheap.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glLoadMatrixd@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glNormal3dv@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glEnd@0
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glVertex3dv@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glBegin@4
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/glovenew.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.


Could you suggest how i could resolve this conflict for these errors? Thanks......
0
 
LVL 6

Accepted Solution

by:
GloomyFriar earned 50 total points
ID: 9644238
Firstly, you have to use or libcid.lib or msvcirt.lib - not both at the same time.
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9644251
LIBCID.LIB - Single threaded, static link
MSVCIRT.LIB - Multithreaded, dynamic link (import library for MSVCI70.DLL)
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9644290
The same with LIBCD.lib and MSVCRT.lib.

MSVCRT.LIB - Multithreaded, dynamic link (import library for MSVCR70.DLL).
LIBCD.LIB - Single-threaded, static link (debug)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9644509
And some functions (__imp__glLoadIdentity, __imp__glLoadMatrixd, ...) are still undefined - you need to add some more lib files.
0
 

Author Comment

by:kvng
ID: 9647644
After resolving the library issues and adding the appropriate libraries, i still get the following errors. Please help? Thanks

Linking...
glovenew.obj : error LNK2001: unresolved external symbol "class ostream_withassign cerr" (?cerr@@3Vostream_withassign@@A)
glovenew.obj : error LNK2001: unresolved external symbol "public: static int const filebuf::openprot" (?openprot@filebuf@@2HB)
glovenew.obj : error LNK2001: unresolved external symbol "class istream_withassign cin" (?cin@@3Vistream_withassign@@A)
glovenew.obj : error LNK2001: unresolved external symbol "class ostream_withassign cout" (?cout@@3Vostream_withassign@@A)
libVHTDevice.lib(vhtIOConn.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::Init(void)" (__imp_??0Init@ios_base@std@@QAE@XZ)
libVHTDevice.lib(vhtIOConn.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::~Init(void)" (__imp_??1Init@ios_base@std@@QAE@XZ)
libVHTDevice.lib(vhtIOConn.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::_Winit(void)" (__imp_??0_Winit@std@@QAE@XZ)
libVHTDevice.lib(vhtIOConn.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::~_Winit(void)" (__imp_??1_Winit@std@@QAE@XZ)
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glLoadMatrixd@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glNormal3dv@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glEnd@0
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glVertex3dv@4
libVHTDevice.lib(vhtOglDrawer.obj) : error LNK2001: unresolved external symbol __imp__glBegin@4
glovenew___Win32_Debug/glovenew.exe : fatal error LNK1120: 14 unresolved externals
Error executing link.exe.
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9648591
What libraries are now connected to the project? Show me all the names.
0
 

Author Comment

by:kvng
ID: 9651253
Hi,

i've managed to solve the problem. It appears that the toolkit i'm using requires the Code generation to be set to 'dll multi-threaded debug' mode and that has been causing the problem.

Thank you for the help.........
0
 

Expert Comment

by:Hyperon
ID: 10479953
Can I also thank you for your help, I'ver struggled with this problem for ages!!!
0
 

Expert Comment

by:shwets
ID: 11174343
Hi

I am trying to use Log4cxx in my source code . All i got was a set of header files for this api ... which I have included in my source and it compiles fine . But it gives a linker error mentioned below. Do I need to register some dll for Log4cxx or just including the header files is enuff' . Also The code generation is set to debug multi threaded dll .

Following is the error that i am getting. Any help would be appreciated.

evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall log4cxx::Logger::forcedLog(class log4cxx::helpers::ObjectPtrT<class log4cxx::Level> const &,class std::basic_string<char,struct std::char_traits<cha
r>,class std::allocator<char> > const &,char const *,int)" (__imp_?forcedLog@Logger@log4cxx@@QAEXABV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDH@Z)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall log4cxx::Logger::isInfoEnabled(void)const " (__imp_?isInfoEnabled@Logger@log4cxx@@QBE_NXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class log4cxx::helpers::ObjectPtrT<class log4cxx::Level> const  log4cxx::Level::INFO" (__imp_?INFO@Level@log4cxx@@2V?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@B
)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall log4cxx::FileAppender::setFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?setFile@Fil
eAppender@log4cxx@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall log4cxx::FileAppender::FileAppender(void)" (__imp_??0FileAppender@log4cxx@@QAE@XZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class log4cxx::helpers::Class const & __cdecl log4cxx::Appender::getStaticClass(void)" (__imp_?getStaticClass@Appender@log4cxx@@SAABVClass@helpers@2@XZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual class log4cxx::helpers::Class const & __thiscall log4cxx::FileAppender::getClass(void)const " (__imp_?getClass@FileAppender@log4cxx@@UBEABVClass@helpers@2@X
Z)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall log4cxx::FileAppender::`vbase destructor'(void)" (__imp_??_DFileAppender@log4cxx@@QAEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::addRef(void)const " (__imp_?addRef@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::releaseRef(void)const " (__imp_?releaseRef@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::lock(void)const " (__imp_?lock@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::unlock(void)const " (__imp_?unlock@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::wait(void)const " (__imp_?wait@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::notify(void)const " (__imp_?notify@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall log4cxx::helpers::ObjectImpl::notifyAll(void)const " (__imp_?notifyAll@ObjectImpl@helpers@log4cxx@@UBEXXZ)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall log4cxx::FileAppender::instanceof(class log4cxx::helpers::Class const &)const " (__imp_?instanceof@FileAppender@log4cxx@@UBE_NABVClass@helpe
rs@2@@Z)
evapp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void const * __thiscall log4cxx::FileAppender::cast(class log4cxx::helpers::Class const &)const " (__imp_?cast@FileAppender@log4cxx@@UBEPBXABVClass@helpers@
2@@Z)
EVPricingService___Win32_Console_Debug/EVPricingService.exe : fatal error LNK1120: 17 unresolved externals
0
 
LVL 13

Expert Comment

by:qwerty021600
ID: 13586613
thnx
0
 
LVL 13

Expert Comment

by:qwerty021600
ID: 13586619
luv u for that
gr8t
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now