作为参考,我首先看到了这篇文章,但它对我没有帮助。我在头文件和 cpp 文件中组织了以下代码。
我正在使用带有cygwin的netbeans。当我编译文件时,我没有收到任何错误,所以我猜这是一个链接器错误。我尝试运行主项目时的错误是:
/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)
请帮帮我。我什至尝试直接从该帖子中复制代码,并且效果很好。绝对没有错误。我是这种类型的代码组织的新手,所以你能帮帮我吗?