Maybe Declaration problems,(nested classes)

Undefined symbols for architecture x86_64:
"entrance::new_processor", referenced from:
entrance::scheduler::update() in ttttt-f058b2.o
entrance::isfree() in ttttt-f058b2.o
entrance::scheduler::dispatch() in ttttt-f058b2.o
"entrance::scheduler::scheduler()", referenced from:
entrance::newscheduler() in ttttt-f058b2.o
___cxx_global_var_init.2 in ttttt-f058b2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here is the error reported on MAC, when I compile the header file, totally fine, but when I compile my source code, seems like there is something wrong with my entrance.h header file, is this a declaration problem? Because I did come across the similar error due to I didn't declare the static function outside classes. But I truly cannot figure out this problem today.
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#ifndef ENTRANCE 
#define ENTRANCE

#include "JobCreate.h"
#include "rbTree.h"
#include "MinHeap.h"
#include "command.h"
//#include "processor.h"
//#include "scheduler.h"
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;




//static vector<string> *original_comm = new vector<string>;

class entrance;

template <typename T>
class rbTree;

class MinHeap;

class JobCreate;

class command;

//class processor;

//class scheduler;


// static MinHeap heap;
// static rbTree<JobCreate> rbt;
// //static scheduler scheduler;
// //static entrance::processor processor;
// static vector<command> commands;
// static vector<string> original_comm;
// static vector<JobCreate> tempjoblist;
class entrance{
	friend class MinHeap;
	friend class JobCreate;
	friend class command;
	template <typename T> 
	friend class rbTree;
public:
	static int time_clock;
	const static string outputpath;

	class processor{
		friend class entrance;
	public:
		int _rtime;
		JobCreate _running;

		processor( const int &rtime, const JobCreate &job )
			:_running(job),_rtime(rtime){}

		processor(){
			this->_running = null;
			this->_rtime = 0;
		}

		void process(){
			_running._excecuted_t++;
			_rtime++;
			if ((_running._total_t - _running._excecuted_t)== 0){

				delete_jobRBT(_running);
				_rtime = 0;
				_running = null;

			}
			else if(_rtime == 5){
				heap.insert(_running);
				_rtime = 0;
				_running = null;
			}
		}
	private:
		JobCreate null;

	};

	class scheduler{
	public:
		scheduler();
		void rawtoreal(){
			for (int i = 0; i < original_comm.size(); ++i){
				commands.push_back(entrance::commandCreate(original_comm[i]));
			}
		}
		
		bool if_command(){
			return (commands.size() != 0) 
				&& (entrance::time_clock==commands[0]._arrive_time);
		}
		void deal_command(const command &command){
			commands.erase(commands.begin());
			if(command._command == "Insert"){
				JobCreate newjob(command._parameters[0],0,command._parameters[1]);
				entrance::insertjob(newjob);
			}
			else if( command._command == "NextJob"){
				entrance::input_to_file(job_to_string(IDsearch(command._parameters[0])));
			}
			else if( command._command == "PreviousJob" ){
				entrance::input_to_file(job_to_string(PREVsearch(command._parameters[0])));				
			}
			else if ( command._command == "PrintJob" ){
				if ( command._parameters.size() == 1 ){
				entrance::input_to_file(job_to_string(IDsearch(command._parameters[0])));
				}
				else{
					entrance::RANGEsearch(command._parameters[0], command._parameters[1]);
					string s;
					if (tempjoblist.size() != 0){
						for (int i = 0; i < tempjoblist.size(); ++i){
							s.append(job_to_string(tempjoblist[i]));
							if ( i != tempjoblist.size() - 1){
								s.push_back(',');
							}
						}
					}
					else{
						JobCreate null(0,0,0);
						s.append(job_to_string(null));
					}
					input_to_file(s);
				}
			}
		}

		void dispatch(){
			JobCreate NextJob;
			if(heap.size() != 0){
				NextJob = heap.removemin();
				new_processor._running = NextJob;
			}
		}

		void update(){
			JobCreate null;
			if (if_command()){
				deal_command(commands[0]);
			}
			if (entrance::isfree()) dispatch();

			if(new_processor._running.equal(null) && commands.size() == 0){
				exit(0);
			}

			if (new_processor._running.equal(null)){}
			else new_processor.process();

			entrance::time_clock++;
		}
	};

	static  entrance::processor new_processor;
	static  MinHeap heap;
	static  rbTree<JobCreate> rbt;
	static  entrance::scheduler new_scheduler;
	static  vector<command> commands;
	static  vector<string> original_comm;
	static  vector<JobCreate> tempjoblist;


	static bool createOutputFile(const string &path);

	MinHeap *newheap() { return new MinHeap(1000);}

	rbTree<JobCreate>  *newrbt() { return new rbTree<JobCreate>();}

	scheduler *newscheduler() { return new entrance::scheduler(); }

	processor *newprocessor() { return new processor();}

	static void input_to_file(const string &s);

	static void read_file( const string &path);

	static int get_time(const string &command);

	static string get_type ( const string &command );

	static vector<int> get_parameters( const string &command );

	static vector<string> split(string& str,const char* c);

	static command commandCreate( const string &origin );

	static string job_to_string(const JobCreate &job);

	static bool isfree(){ 
		JobCreate null;
		return (new_processor._running.equal(null));
	}

	static void insertjob(const JobCreate &job) {
		heap.insert(job); rbt.insert(job);
	}

	static void delete_jobRBT(JobCreate job) {rbt.remove(job);}  ////prob

	static JobCreate IDsearch(const int &jobid ){
		JobCreate temp(jobid, 0, 0);
		JobCreate res = rbt.search(rbt.root(), temp)->getKey();
		JobCreate null;
		if (res.equal(null)){
			return null;
		}
		else return res;
	}

	static JobCreate NEXTsearch(const int &jobid ){
		JobCreate temp(jobid,0,0);
		JobCreate res = rbt.next(rbt.root(),temp);
		JobCreate null;
		if (res.equal(null)){
			return null;
		}
		else return res;
	}

	static JobCreate PREVsearch(const int &jobid ){
		JobCreate temp(jobid,0,0);
		JobCreate res = rbt.previous(rbt.root(),temp);
		JobCreate null;
		if (res.equal(null)){
			return null;
		}
		else return res;
	}

	static void RANGEsearch(const int &jobid, const int &jobid2){
		JobCreate job1(jobid,0,0);
		JobCreate job2(jobid2,0,0);
		rbt.between(rbt.root(),job1,job2);
	}
};

//vector<string>* entrance::original_comm = new vector<string>;
// const string entrance:: outputpath ="output_file.txt";
int entrance::time_clock;

#endif 


source code

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


#include "JobCreate.h"
#include "rbTree.h"
#include "MinHeap.h"
#include "command.h"
#include "entrance.h"

using namespace std;

MinHeap entrance::heap;
rbTree<JobCreate> entrance::rbt;
entrance::scheduler new_scheduler;
entrance::processor new_processor;
vector<command> entrance::commands;
vector<string> entrance::original_comm;
vector<JobCreate> entrance::tempjoblist;
const string entrance:: outputpath ="output_file.txt";

int main(){
	//processor processor;
	//command command;
	entrance main;
	entrance::createOutputFile(entrance::outputpath);
	MinHeap* heap = main.newheap();
	rbTree<JobCreate>* rbt = main.newrbt();
	entrance::scheduler* new_scheduler = main.newscheduler();
	entrance::processor* new_processor = main.newprocessor();
	entrance::read_file("input_file.txt");
	new_scheduler->rawtoreal();
	while(true){
		new_scheduler->update();
	}
}
Line 165/168: You can omit entrance:: since you are within that scope.

Line 13/14 requires the scope operator:
1
2
entrance::scheduler entrance::new_scheduler;
entrance::processor entrance::new_processor;
Last edited on
Thanks guy, rly help me a lot
Topic archived. No new replies allowed.