I get this error and I'm not sure how to fix it. The request constructor takes a string type, I don't think I implemented properly in my request.h file. Error:
Undefined first referenced
symbol in file
Request::Request(char *, int, int) threadtest.o
ld: fatal: Symbol referencing errors. No output written to nachos
code:
class Request
{
public:
//constructor intializes request type
Request(char *u, int rqtID, int rqtrID);
char *url;
int requestID;
int requesterID;
};
request.cc file where constructor is defined
#include "request.h"
Request :: Request(char *urll, int requestIDD, int requesterIDD )
{
url = *urll
requestID = requestIDD;
requesterID = requesterIDD;
}
Lets try to understand the error first.
ld: fatal: Symbol referencing errors. No output written to nachos
This means it is a linking issue. Linker is unable to find definitions for some symbols.
Undefined first referenced symbol in file Request::Request(char *, int, int) threadtest.o
Important information here is - Request::Request(char *, int, int)
and threadtest.o
. So, you have a source file name threadtest.cpp
where you are instantiating Request
object. Understand that inclusion of a header ( probably Request.h
in threadtest.cpp
) helps compiler to find the declarations. Linker tries to find definitions of symbols from all object files and forms an executable.
So, possibly you are not compiling Request.cpp
or forgot to link Request.o
.