无法运行项目,将多个文件组织到标头和cpp中

时间:2013-03-23 10:49:46

标签: c++ templates

作为我的参考,我首先看到this帖子,但它对我没有帮助。我在header和cpp文件中组织了以下代码。

enter image description here

我正在使用netbeans和cygwin。当我编译文件时,我没有收到任何错误,所以我猜这是一个链接器错误。我尝试运行主项目时的错误是:

/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)

请帮帮我。我甚至尝试直接从that帖子中复制代码,它工作得非常好。完全没有错误。我是这类代码组织的新手,所以能帮帮我吗?

0 个答案:

没有答案