I have been chasing this bug all night! When I go to link my code it gives me the error:
It is called from here:webCrawlerTest.cpp.text+0x1ad): undefined reference to `stopWord::Test(std::basic_ostream<char, std::char_traits<char> >&)'
The class it's calling is here:Code:int main(int argc, char* argv[]) { LinkedList<string>::Test(cout); HashSet<string>::Test(cout); stopWord::Test(cout); //HERE IS THE FUNCTION CALL return 0; }
Finally for completness' sake, here is the makefile I'm using. It should be easy to understand.Code:include "stopWord.h" #include "UnitTest.h" #include <sstream> using namespace std; //Include file has a private HashSet called stopWords that contains all the stop words stopWord::stopWord(std::fstream & file) { string line, word; while(file>>line) { std::stringstream wholeLine(line); while(wholeLine>>word) stopWords.Add(&word); } } bool stopWord::Contains(std::string &s) { return stopWords.Contains(s); } static bool Test(ostream & os) { os<<"Begin stop word testing\r\n"; bool success = true; fstream file; file.open("tests/stop.txt"); TEST(file); stopWord test(file); string testStr="been"; TEST(test.Contains(testStr)); testStr="into"; TEST(test.Contains(testStr)); testStr="z"; TEST(test.Contains(testStr)); testStr="mancala"; TEST(!test.Contains(testStr)); file.close(); return success; }
PLEASE PLEASE PLEASE help. I can't figure this one out! Thanks you guys!Code:# Dustin Nicholes # CS 240 makefile project # October 8, 2008 BIN_FILE = bin/webCrawler OBJ_FILES = obj/webCrawler.o obj/stopWord.o obj/URL.o TEST_OBJ = obj/webCrawlerTest.o obj/stopWord.o obj/URL.o HEADER_FILES = inc/URL.h inc/HashSet.h inc/LinkedList.h inc/stopWord.h LIB_OBJ = utils/obj/CommandRunner.o utils/obj/FileInputStream.o utils/obj/FileSystem.o utils/obj/HTTPInputStream.o utils/obj/InputStream.o\ utils/obj/StringUtil.o LIB_NAME = lib/cs240Utils.a TEST_FILE = bin/webCrawlerTest EXE_FILE = bin/webCrawler LIB = #-lboost_program_options -lboost_filesystem -lboost_iostreams #### bin command bin : $(BIN_FILE) $(BIN_FILE) : $(OBJ_FILES) $(LIB_NAME) g++ -g -Wall -o $(BIN_FILE) $(OBJ_FILES) -lboost_regex $(LIB_NAME) chmod ugo+x $(BIN_FILE) obj/webCrawler.o : src/webCrawler.cpp inc/HashSet.h inc/LinkedList.h inc/stopWord.h inc/URL.h g++ -c -o obj/webCrawler.o -I utils/include -I inc src/webCrawler.cpp $(LIB) obj/stopWord.o : src/stopWord.cpp inc/stopWord.h inc/HashSet.h inc/LinkedList.h inc/URL.h g++ -c -o obj/stopWord.o -I utils/include -I inc src/stopWord.cpp $(LIB) obj/URL.o : src/URL.cpp inc/HashSet.h inc/LinkedList.h inc/stopWord.h inc/URL.h g++ -c -o obj/URL.o -I utils/include -I inc src/URL.cpp $(LIB) run : $(EXE_FILE) $(EXE_FILE) #### test command test : $(TEST_FILE) run_test $(TEST_FILE) : $(TEST_OBJ) $(LIB_NAME) g++ -g -Wall -o $(TEST_FILE) $(TEST_OBJ) -lboost_regex $(LIB_NAME) chmod ugo+x $(TEST_FILE) obj/webCrawlerTest.o : src/webCrawlerTest.cpp inc/HashSet.h inc/LinkedList.h inc/stopWord.h inc/URL.h g++ -c -o obj/webCrawlerTest.o -I utils/include -I inc src/webCrawlerTest.cpp $(LIB) run_test : $(TEST_FILE) $(TEST_FILE) #### build lib files lib : $(LIB_NAME) $(LIB_NAME) : $(LIB_OBJ) ar r $(LIB_NAME) $(LIB_OBJ) utils/obj/CommandRunner.o : utils/src/CommandRunner.cpp utils/include/CS240Exception.h utils/include/StringUtil.h utils/include/CommandRunner.h g++ -c -o utils/obj/CommandRunner.o -I utils/include utils/src/CommandRunner.cpp utils/obj/FileInputStream.o : utils/src/FileInputStream.cpp utils/include/InputStream.h utils/include/FileInputStream.h utils/include/CS240Exception.h g++ -c -o utils/obj/FileInputStream.o -I utils/include utils/src/FileInputStream.cpp utils/obj/FileSystem.o : utils/src/FileSystem.cpp utils/include/FileSystem.h utils/include/CS240Exception.h utils/include/UnitTest.h g++ -c -o utils/obj/FileSystem.o -I utils/include utils/src/FileSystem.cpp utils/obj/HTTPInputStream.o : utils/src/HTTPInputStream.cpp utils/include/CS240Exception.h \ utils/include/StringUtil.h utils/include/HTTPInputStream.h utils/include/InputStream.h g++ -c -o utils/obj/HTTPInputStream.o -I utils/include utils/src/HTTPInputStream.cpp utils/obj/InputStream.o : utils/src/InputStream.cpp utils/include/StringUtil.h utils/include/HTTPInputStream.h \ utils/include/FileInputStream.h utils/include/InputStream.h g++ -c -o utils/obj/InputStream.o -I utils/include utils/src/InputStream.cpp utils/obj/StringUtil.o : utils/src/StringUtil.cpp utils/include/StringUtil.h g++ -c -o utils/obj/StringUtil.o -I utils/include utils/src/StringUtil.cpp #### clean command clean : - rm -f obj/* - rm -f bin/* - rm -f lib/* - rm -f utils/obj/*



LinkBack URL
About LinkBacks
.text+0x1ad): undefined reference to `stopWord::Test(std::basic_ostream<char, std::char_traits<char> >&)'




