我目前在學習C++與Stroustrup編程:原理和實踐使用C++,並在第12章。我現在試圖從FLTK獲得特定標頭的工作。FLTK不能與Stroustrup標題一起工作
我已經安裝了MacPorts的FLTK。當我試圖編譯包括Simple_window.h的代碼時,出現以下錯誤:
bash-3.2# fltk-config --compile main.cpp
/usr/bin/g++-4.2 -arch i386 -I/opt/local/include -pipe -arch i386 -arch i386
-D_THREAD_SAFE -D_REENTRANT -o main main.cpp -arch i386 -arch i386
/opt/local/lib/libfltk.a -lpthread -framework Carbon -framework
ApplicationServices
Undefined symbols:
"vtable for Graph_lib::Window", referenced from:
__ZTVN9Graph_lib6WindowE$non_lazy_ptr in cc1oxcSA.o
(maybe you meant: __ZTVN9Graph_lib6WindowE$non_lazy_ptr)
"vtable for Graph_lib::Button", referenced from:
__ZTVN9Graph_lib6ButtonE$non_lazy_ptr in cc1oxcSA.o
(maybe you meant: __ZTVN9Graph_lib6ButtonE$non_lazy_ptr)
"Simple_window::Simple_window(Point, int, int, String const&)", referenced from:
_main in cc1oxcSA.o
"Graph_lib::Window::draw()", referenced from:
vtable for Simple_windowin cc1oxcSA.o
"typeinfo for Graph_lib::Window", referenced from:
typeinfo for Simple_windowin cc1oxcSA.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
我不知道這是什麼意思。我讀了here (SO)的答案。我創建了.o文件。我試圖用fltk-config在Mac OS上進行編譯。
您沒有正確鏈接並忘記了目標文件?你需要將它們包含在命令行中。 – pmr 2011-12-31 13:40:52
@pmr可能的,但我是一個初學者,所以我如何包括他們? – MCPP 2011-12-31 13:48:30