0

For my reference, first I saw this post, but it didn't help me. I have the following code organised in headers and cpp files.

enter image description here

I am using netbeans with cygwin. When I compile the files, I don't get any error so I guess it is a linker error. The errors when I get trying to run the main project are:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS'
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_1-Windows/EDS.exe
make[2]: Entering directory `/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS'
mkdir -p dist/Debug/Cygwin_1-Windows
g++.exe     -o dist/Debug/Cygwin_1-Windows/EDS build/Debug/Cygwin_1-Windows/SortedListClass.o  build/Debug/Cygwin_1-Windows/ListNodeClass.o  build/Debug/Cygwin_1-Windows/main.o  
build/Debug/Cygwin_1-Windows/main.o: In function `main':
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:13: undefined reference to `SortedListClass<int>::SortedListClass()'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:25: undefined reference to `SortedListClass<int>::insertValue(int const&)'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:29: undefined reference to `SortedListClass<int>::removeFront(int&)'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:40: undefined reference to `SortedListClass<int>::printForward() const'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:43: undefined reference to `SortedListClass<int>::printBackward() const'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:46: undefined reference to `SortedListClass<int>::clear()'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:49: undefined reference to `SortedListClass<int>::getNumElems() const'
/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS/main.cpp:56: undefined reference to `SortedListClass<int>::getElemAtIndex(int, int&)'
collect2: ld returned 1 exit status
nbproject/Makefile-Debug.mk:59: recipe for target `dist/Debug/Cygwin_1-Windows/EDS.exe' failed
make[2]: *** [dist/Debug/Cygwin_1-Windows/EDS.exe] Error 1
make[2]: Leaving directory `/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS'
nbproject/Makefile-Debug.mk:56: recipe for target `.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/i/Codes/Windows 7 Ultimate/NetBeansProjects/EDS'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)

Please help me out. I even tried out directly copying the code from that post and it worked perfectly fine. with absolutely no errors. I am new to this type of code organising so can you please help me out?

Community
  • 1
  • 1
killerCoder
  • 407
  • 2
  • 7
  • 14
  • 2
    You cannot put the definition of member functions of a class template in a `.cpp` file (unless you do manual explicit instantiations). Move them to the same header where the class template definition is found. – Andy Prowl Mar 23 '13 at 10:50
  • Ok.. Thanks a lot. Should I delete this question? – killerCoder Mar 23 '13 at 10:53
  • @Andy Prowl : Thanks.. You saved me a lot of time. Why don't you paste the comment as an answer and Ill be pleased to accept it? – killerCoder Mar 23 '13 at 10:58
  • You're welcome. I won't paste it as an answer because the answer is already in another question (the one I linked). You do not need to delete this question, but it will be likely closed and associated to the other one – Andy Prowl Mar 23 '13 at 11:07

0 Answers0