LNK2019 problems

  • Thread starter Thread starter walsht
  • Start date Start date
W

walsht

I'm trying to make a linked list available to all my classes that need
to be able to access the list. I've made a header file Main.h (contents
below) that is being included in the relavent files. When I compile
with VC 2005 I get the following error.

1>------ Build started: Project: Backend, Configuration: Debug Win32
------
1>Compiling...
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol "public:
__thiscall LinkedList<class Message *>::LinkedList<class Message
*>(void)" (??0?$LinkedList@PAVMessage@@@@QAE@XZ) referenced in function
_main
1>C:\Documents and Settings\Amanda\My Documents\Visual Studio
2005\Projects\Thesis\Debug\Backend.exe : fatal error LNK1120: 1
unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Amanda\My
Documents\Visual Studio
2005\Projects\Thesis\Backend\Debug\BuildLog.htm"
1>Backend - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========


The contents of Main.h :
#include "Graph.h"
#include "Message.h"
#include "LinkedList.h"

extern LinkedList<Message*> * EmailMessages;

The contents of Main.cpp:
#include "Main.h"
#include "LinkedList.h"
#include "Message.h"

int main()
{
LinkedList<Message*> * EmailMessages = new LinkedList<Message*>();
//extern LinkedList<Message*> EmailMessages;
return 0;
}


Any suggestions?
 
I'm trying to make a linked list available to all my classes that need
to be able to access the list. I've made a header file Main.h (contents
below) that is being included in the relavent files. When I compile
with VC 2005 I get the following error.

1>------ Build started: Project: Backend, Configuration: Debug Win32
------
1>Compiling...
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol "public:
__thiscall LinkedList<class Message *>::LinkedList<class Message
*>(void)" (??0?$LinkedList@PAVMessage@@@@QAE@XZ) referenced in function
_main
1>C:\Documents and Settings\Amanda\My Documents\Visual Studio
2005\Projects\Thesis\Debug\Backend.exe : fatal error LNK1120: 1
unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Amanda\My
Documents\Visual Studio
2005\Projects\Thesis\Backend\Debug\BuildLog.htm"
1>Backend - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========


The contents of Main.h :
#include "Graph.h"
#include "Message.h"
#include "LinkedList.h"

extern LinkedList<Message*> * EmailMessages;

The contents of Main.cpp:
#include "Main.h"
#include "LinkedList.h"
#include "Message.h"
LinkedList said:
int main()
{
EmailMessages = new LinkedList said:
//extern LinkedList<Message*> EmailMessages;
return 0;
}


Any suggestions?
You have to declare EmailMessages as a global variable in order to match
the extern linkage.
 
(e-mail address removed) wrote in @i3g2000cwc.googlegroups.com:
I'm trying to make a linked list available to all my classes that need
to be able to access the list. I've made a header file Main.h (contents
below) that is being included in the relavent files. When I compile
with VC 2005 I get the following error.
[snip]


Any suggestions?


In Main.cpp outside of the main() function add this line:

LinkedList<Message*>* EmailMessages = NULL;
 
1>------ Build started: Project: Backend, Configuration: Debug Win32
------
1>Compiling...
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol "public:
__thiscall LinkedList<class Message *>::LinkedList<class Message
*>(void)" (??0?$LinkedList@PAVMessage@@@@QAE@XZ) referenced in function
_main

You forgot to include LinkedList.cpp in your project?
 
Back
Top