Unresolved externals LNK2019 & LNK1120

Hi

I'm having this problem with unresolved externals that really preventing me from......enjoying life. It is with the specific code that is posted below, and it's something that has taken a lot of points out of an in-class test I otherwise excelled on. I tried asking my professor what could possibly be wrong with it when everything looks great logically and he is just telling me that I need to spend hours "just working through it". I literally haven't a clue what is wrong with the following code and I've had this recurring problem for 3 weeks now and I've searched every internet resource, got banned from Stack Overflow, and have no other way of getting help except here. I'm pretty much on the verge of emotionally breaking down because of this single issue.

note: this CPP file uses a header file that has been provided by the professor which basically makes the Node struct Item & Next private data and uses the getItem(), getNext(), setItem(), and setNext() functions to access them. I don't want to post it because it is too much code for one question imo but I'll post it if requested to.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//LinkedSortedList.h File

#ifndef _LINKEDSORTED_LIST
#define _LINKEDSORTED_LIST
#include"Node.h"

template<class ItemType>
class LinkedSortedList
{
private:
	Node<ItemType> *head;
	int itemCount;		
	//Node<ItemType> *getNodeBefore(const ItemType &anEntry)const;
	Node<ItemType> *getNodeAt(int position) const; 
public:
	LinkedSortedList(); 
	LinkedSortedList(const LinkedSortedList<ItemType> &aList); //Copy constructor
	bool isEmpty() const;  
	int getLength() const; 
	bool remove(int position); 
	void clear(); 
	ItemType getEntry(int position) const; 
	void displayList();

	/*Following are three new methods:
	void insertSorted(const ItemType &newEntry);
	bool removeSorted(const ItemType &anEntry);
	int getPosition(const ItemType &newEntry)const;*/
};

template<class ItemType>
LinkedSortedList<ItemType>::LinkedSortedList (){
	head=NULL;
	itemCount=0;
}

template<class ItemType>
LinkedSortedList<ItemType>::LinkedSortedList(const LinkedSortedList<ItemType> &aList){
	head=aList;
	itemCount=0;
    Node<ItemType> *findItemCount=head;
    (while findItemCount!=NULL){
        findItemCount=findItemCount->getNext();
        itemCount++;
    } 
}

template<class ItemType>
Node<ItemType> *LinkedSortedList<ItemType>::getNodeAt(int position) const{
    if(position<0 || position>itemCount){
        cout<<"Invalid position! Program aborted!\n";
        exit(1);
    }
    Node<ItemType> *nodePtr=head;
      for(int i=1;i<position;i++)
        nodePtr=nodePtr->getNext();
    return nodePtr;
} 

template<class ItemType>
bool LinkedSortedList<ItemType>::isEmpty() const {
	return itemCount==0;
}

template<class ItemType>
int LinkedSortedList<ItemType>::getLength() const {
	return itemCount;
}

template<class ItemType>
bool LinkedSortedList<ItemType>::remove(int position) {
	bool ableToRemove=(position>=1) && (position<=itemCount)
    if(ableToRemove){
        Node<ItemType> *nodePtr;
        if(position==1){
			nodePtr=head;
            nodePtr=nodePtr->getNext();
            head=nodePtr;
        } else if (position==itemCount) {
        	nodePtr=getNodeAt(position-1);
        	deletePtr=nodePtr->getNext();
        	nodePtr->setNext(NULL);
        	deletePtr=NULL;
            delete deletePtr;
        } else {
        	nodePtr=getNodeAt(position-1);
        	Node<ItemType>* deletePtr = nodePtr->getNext();
        	nodePtr->setNext(deletePtr->getNext());
        	deletePtr=NULL;
            delete deletePtr;
        }
	}
    return ableToRemove;
}

template<class ItemType>
void LinkedSortedList<ItemType>::clear(){
	itemCount=0;
}		

template<class ItemType>
ItemType LinkedSortedList<ItemType>::getEntry(int position) const {
	bool ableToGet=(position>=1) && (position<=itemCount);
    if(ableToGet){
        Node<ItemType> *nodePtr=getNodeAt(position);
        return nodePtr->getItem();
    }
    else
        throw logic_error("You tried to getEntry().....BUT FAILED");
} 



template<class ItemType>
void LinkedSortedList<ItemType>::displayList(){
	for(int i=0; i<itemCount; i++)
		cout<<getEntry(i+1)<<endl;
}



#endif


You need to post the exact error message you received.
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup - MSVCRTD.lib(crtexe.obj)
error LNK1120: 1 unresolved error - [myprojectname].exe
You seem to be compiling your project as a CRT one rather than a native console app. You can make a new empty project and it should work, or go into the settings and change that option.
I don't understand. When I was originally prompted to create a new project, I made it a Win 32 Console Application and checked the boxes for "Console application" and "empty project".

I'm sorry if I sound obtuse.
Double check anyways.
I'm assuming you're using the visual C++ IDE?

Navigate to View>Property Pages>Configuration Properties>Linker>System>SubSystem. Confirm that the subsystem is "Console(/SUBSYSTEM:CONSOLE)"
robertpires wrote:
When I was originally prompted to create a new project, I made it a Win 32 Console Application
This is the issue. You have to make an Empty Project and not a Win32 Console Project. The people at Microsoft are trying to abduct your programming and lock you to their platform.
Thanks LB that solved the unresolved externals problem. I'm now getting a LNK 1561 error about not setting up an entry point but after quickly looking it up, it's because I didn't write a main function. I think this is good.....
Topic archived. No new replies allowed.