9 Replies - 1274 Views - Last Post: 28 July 2009 - 06:30 AM Rate Topic: -----

#1 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

unresolved external symbol..

Posted 27 July 2009 - 03:16 PM

I'm implementing list with templates for my test, and I have these errors:

----------------------------------------------------------
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall List<char>::~List<char>(void)" (??1?$List@D@@QAE@XZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "public: int __thiscall List<char>::GetLength(void)const " (?GetLength@?$List@D@@QBEHXZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall List<char>::List<char>(void)" (??0?$List@D@@QAE@XZ) referenced in function _main
1>C:\Documents and Settings\Oron\My Documents\Visual Studio 2008\Projects\LisstProject\Debug\ListProject.exe : fatal error LNK1120: 3 unresolved externals
----------------------------------------------------------

I don't know what to do : //
This is probably not an include problem, but I'll write it anyway:

h files:

Head
List
Node

cpp files:
Head (include Head.h)
Node (include Node.h)
List (include Node.h and Head.h)
Main (include List.h)

I read some things about .lib files that I should add the project, but it didn't work for me
I'm using VS2008

Please Help..It's very important

Is This A Good Question/Topic? 0
  • +

Replies To: unresolved external symbol..

#2 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: unresolved external symbol..

Posted 27 July 2009 - 03:17 PM

Post main() and list.cpp please. And don't forget to use the code tags.

This post has been edited by apw5020: 27 July 2009 - 03:18 PM

Was This Post Helpful? 0
  • +
  • -

#3 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: unresolved external symbol..

Posted 27 July 2009 - 03:34 PM

Main:
#include <iostream>
#include "List.h"
using namespace std;

int main()
{
	List<char> l;
	cout<<"Num Nodes:"<<l.GetLength()<<endl;
	return 0;
}


List.cpp
#include <iostream>
#include "List.h"

template <class T>
List<T>::List()
{
	head = new Head<T>();
	size = 0;
};

template <class T>
List<T>::~List()
{
	Node<T> *curr = head->head;
	if (curr != NULL)
	{
		Node<T> *next = curr->next;
		while (next != NULL)
		{
			delete curr;
			curr = next;
			next = curr->next;
		}

		delete curr;
	}
};

template <class T>
int List<T>::GetLength() const
{
	if (head == NULL)
		return 0;
	else
		return size;
};


Was This Post Helpful? 0
  • +
  • -

#4 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: unresolved external symbol..

Posted 27 July 2009 - 04:03 PM

Variable names cannot start with a number. Try renaming your List instance in main() and let me know what happens.

EDIT

Why don't you put everything in your List.h file? I don't think you need semicolons after each function definition.

This post has been edited by apw5020: 27 July 2009 - 04:17 PM

Was This Post Helpful? 0
  • +
  • -

#5 Erik Drakken  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 22
  • Joined: 24-July 09

Re: unresolved external symbol..

Posted 27 July 2009 - 04:07 PM

View PostFoodGood, on 27 Jul, 2009 - 04:16 PM, said:

I'm implementing list with templates for my test, and I have these errors:

----------------------------------------------------------
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall List<char>::~List<char>(void)" (??1?$List@D@@QAE@XZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "public: int __thiscall List<char>::GetLength(void)const " (?GetLength@?$List@D@@QBEHXZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall List<char>::List<char>(void)" (??0?$List@D@@QAE@XZ) referenced in function _main
1>C:\Documents and Settings\Oron\My Documents\Visual Studio 2008\Projects\LisstProject\Debug\ListProject.exe : fatal error LNK1120: 3 unresolved externals
----------------------------------------------------------

I don't know what to do : //
This is probably not an include problem, but I'll write it anyway:

h files:

Head
List
Node

cpp files:
Head (include Head.h)
Node (include Node.h)
List (include Node.h and Head.h)
Main (include List.h)

I read some things about .lib files that I should add the project, but it didn't work for me
I'm using VS2008

Please Help..It's very important


Did you add them in the format #pragma comment(lib,"YourLib.lib")?
Was This Post Helpful? 0
  • +
  • -

#6 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: unresolved external symbol..

Posted 27 July 2009 - 04:22 PM

apw5020:
It is 'l' character :)
You actually scared me LOL

Erik Drakken:
I have no idea what are you talking about :P
I added them through the project properties, and they have cause even more errors so I got rid of them :v:
Was This Post Helpful? 0
  • +
  • -

#7 Erik Drakken  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 22
  • Joined: 24-July 09

Re: unresolved external symbol..

Posted 27 July 2009 - 06:14 PM

I can't make any guarantees, but in my experience, adding them via #pragma comment as I showed above has rectified my library issues without fail. I haven't had such luck when adding them via the project properties. Hopefully you'll have the same luck I have. :P

Also, remember that "YourLib.lib" is to be replaced by the actual name of the library you want to load with that line.

Edit: Typos

This post has been edited by Erik Drakken: 27 July 2009 - 06:16 PM

Was This Post Helpful? 0
  • +
  • -

#8 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: unresolved external symbol..

Posted 28 July 2009 - 03:21 AM

:/ :/ :/ :/
Don't know what to do

VC++ express was great..God knows why did I upgrade to VS 2008
Was This Post Helpful? 0
  • +
  • -

#9 ladyinblack  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 9
  • View blog
  • Posts: 419
  • Joined: 08-April 09

Re: unresolved external symbol..

Posted 28 July 2009 - 04:54 AM

The cpp file you are running, is it your main file? What is the name of your main cpp?

Try this:

#include <iostream>
#include "List.h"
#include "Head.h"
#include "Node.h"

template <class T>
List<T>::List()
{
	head = new Head<T>();
	size = 0;
};


Add the head and node header includes in you list file and see what happens. I'm only guessing, because your error is not giving any syntax or code related errors, it only saying that it ain't linking. So, I figure since you are instantiating the Head in your List constructor, perhaps you need that and your Node in your destructor your would need that as well.

I don't really think there is anything seriously wrong with VS2008, then again I have used it yet.
Was This Post Helpful? 0
  • +
  • -

#10 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: unresolved external symbol..

Posted 28 July 2009 - 06:30 AM

My main file is Main.cpp
I've already posted the code..It's on this page somewhere
And your suggestion is not working :/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1