0

参考までに、最初にこの投稿を見ましたが、役に立ちませんでした。次のコードをヘッダーと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)

私を助けてください。その投稿からコードを直接コピーしてみたところ、問題なく動作しました。エラーはまったくありません。私はこのタイプのコード編成に慣れていないので、手伝ってくれませんか?

4

0 に答える 0