我想在Netbeans的 C++爲Mac做一個項目,當我一個名爲SERVICIO類做一個簡單的構造函數,編譯器顯示我下面的錯誤:未定義的符號
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/medicos
mkdir -p dist/Debug/GNU-MacOSX
g++ -o dist/Debug/GNU-MacOSX/medicos build/Debug/GNU-MacOSX/agenda.o build/Debug/GNU-MacOSX/cita.o build/Debug/GNU-MacOSX/contenedor.o build/Debug/GNU-MacOSX/doctor.o build/Debug/GNU-MacOSX/fecha.o build/Debug/GNU-MacOSX/main.o build/Debug/GNU-MacOSX/objetoBase.o build/Debug/GNU-MacOSX/paciente.o build/Debug/GNU-MacOSX/padecimiento.o build/Debug/GNU-MacOSX/servicio.o
Undefined symbols for architecture x86_64:
"vtable for servicio", referenced from:
servicio::servicio(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in servicio.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dist/Debug/GNU-MacOSX/medicos] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
我不太確定問題可能是什麼,我是編程初學者,所以我對此不甚瞭解,謝謝幫助。
請向我們展示相關的代碼。 – stefan
在QT的情況下,這通常意味着您沒有重建需要重建的所有內容。 –
這是h文件: 的#ifndef SERVICIO_H使用命名空間std 的#define \t SERVICIO_H 的#include ; class servicio { public: servicio(string); 虛擬字符串toString()const; virtual〜servicio(); private: string nombre; }; #ENDIF \t/* * SERVICIO_H/ ,這是在.cpp: 的#include 「servicio.h」 SERVICIO :: SERVICIO(字符串農佈雷):農佈雷(農佈雷){ } 只是想做這個簡單的構造函數 –
ChrisU