Error Help Request : "undefined reference to..."

I'm working on unit testing an assignment of mine, and i'm at a loss. Can someone help me understand what is going on here?

Below, in order is (1) the output from make (2) the tester file, test.cc (3) the header file for the .cc being test, called msg.h (4) makefile

Thanks for your time

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
253
254
255
//**OUTPUT*FROM*MAKE*********************************************************
g++   -std=c++11   -Wall       -c   msg.cc 
g++   -std=c++11   -Wall       -c   test.cc
g++   -std=c++11   -Wall       -o   test msg.o test.o

test.o: In function `main':
test.cc:(.text+0x6b): undefined reference to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

test.cc:(.text+0xd2): undefined reference to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

test.cc:(.text+0x139): undefined reference to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

test.cc:(.text+0x1a0): undefined reference to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

test.cc:(.text+0x207): undefined reference to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

test.o:test.cc:(.text+0x26f): more undefined references to `Message::Validate(std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&)' follow

collect2: error: ld returned 1 exit status
makefile:11: recipe for target 'test' failed
make: *** [test] Error 1

//**Test.cc*********************************************************

#include "msg.h"

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <string>
using std::string;
using std::to_string;

#include <cstdlib>
using std::rand;
using std::srand;

#include <ctime>
using std::time;

string Create_Correct_Ones();
string Create_Correct_Tens();
string Create_Correct_Hundreds();
string Create_Correct_Thousands();
string Create_No_M();
string Create_No_Percent_One();
string Create_No_Percent_Two();
string Create_Non_Int();
string Create_End_Early();
int Test_GetBodyLength();
int Test_GetBody();

int main(int argc, char* argv[]) {
  cout << "" << endl;
  cout << "TESTING VALIDATE:" << endl;

  if(Message :: Validate(Create_Correct_Ones()) != 0)
    cout << "TEST Create_Correct_Ones() Failed    EXPECTED: PASSED" << endl;
  else
    cout << "TEST Create_Correct_Ones() Passed    EXPECTED: PASSED" << endl;
  
  //Format above repeated for all tests

  return 0;
}

//**************************************************************

// Returns a string with correct message formating for a message with a 
// length that is less than ten characters in length

string Create_Correct_Ones(){
  //Left Empty  
} 

//**************************************************************

// Returns a string with correct message formating for a message with a 
// length that is less than one-hundred characters in length

string Create_Correct_Tens(){
  //Left Empty
} 

//**************************************************************

// Returns a string with correct message formating for a message with a 
// length that is less than one-hundred characters in length

string Create_Correct_Hundreds(){
  //Left Empty
} 

//**************************************************************

// Returns a string with correct message formating for a message with a 
// length that is less than one-thousand characters in length

string Create_Correct_Thousands(){
  //Left Empty
} 

//**************************************************************

// Returns a string with a message that is missing the m formating

string Create_No_M(){
  //Left Empty
}

//**************************************************************

// Returns a string with a message that is missing the first %

string Create_No_Percent_One(){
  //Left Empty
}

//**************************************************************

// Returns a string with a message that is missing the second %
string Create_No_Percent_Two(){
  //Left Empty
}

//**************************************************************

// Returns a string with a message that has a non-int in formating
string Create_Non_Int(){
  //Left Empty
}

//**************************************************************

// Returns a string with a message that ends early
string Create_End_Early(){
  //Left Empty
}

//**************************************************************

// Tests function of GetBody() 
int Test_GetBody(){
  //Left Empty
}

//**msg.h********************************************************

//#ifndef _HW3_INCLUDE_MSG_H_ // NOLINT
//#define _HW3_INCLUDE_MSG_H_ // NOLINT

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using std::string;
using std::to_string;

class Message {
 public:

 // static methods
  /*  Validates a message string e.g. m%6%my msg  */
  static int Validate(const std::string& msg);
  /*  Creates a from a message string e.g. m%6%my msg  */
  static const Message MsgFromMsgStr(const std::string& msg);

//**************************************************************
 // constructors
  /* Sets Message instance's body to empty string  */
  Message(); // NOLINT
  /*  Sets Message instance's body to char array parameter  */
  Message(const char body[]); // NOLINT
  /*  Sets Message instance's body to string parameter.  */
  Message(const std::string& body); // NOLINT

//**************************************************************

 // accessors
  const std::string GetBody() const;
  /*
   *  Returns the length of the Message instance's body.
   */
  unsigned int GetLength() const;

  /*
   *  Returns a string message of the form m%<body length>%<body>
   */
  const std::string ToString() const;

//**************************************************************

 // mutators
  /*
   *  Method accepts a string and appends it to the Message instance's body.
   */
  void AppendToBody(const std::string& body);

//**************************************************************

 // comparators
  /*
   *  Returns true if two messages have the same body.
   */
  bool Equals(const Message& that) const;

//**************************************************************

 // operators
  /*
   *  Operator accepts a string which is appended to the Message's body
   *  and returned as a new Message.
   */
  const Message operator+(const std::string& body) const;

  /*
   *  Returns true if two messages have the same body.
   */
  bool operator==(const Message& that) const;
 
//**************************************************************

 private:
  string msg_;
  int length_;
};

//**MAKEFILE****************************************************

CC = g++  # use g++ compiler

FLAGS = -std=c++11  # compile with C++ 11 standard
FLAGS += -Wall      # compile with all warnings

LINK = $(CC) $(FLAGS) -o  # final linked build to binary executable

COMPILE = $(CC) $(FLAGS) -c  # compilation to intermediary .o files

test : msg.o test.o
	$(LINK) $@ $^

test.o : test.cc msg.h
	$(COMPILE) $<

msg.o : msg.cc msg.h
	$(COMPILE) $< 

clean:
	@rm test *.o

//************************************************************** 
Presumably there's something wrong with your definition of
 
  static int Validate(const std::string& msg);

in msg.cc. But you didn't show that file.
Topic archived. No new replies allowed.