尝试运行 fltk 但会出现未定义的错误

尝试运行 fltk 但会出现未定义的错误

我正在尝试编译一个旧的编程作业,当使用我的学校服务器时,它可以无错误地编译,并且现在仍然可以工作。我尝试在我的家用计算机上进行编译,但当我执行以下操作时会出现此错误:

g++      -std=c++11        -c -o Graph.o Graph.cpp
g++      -std=c++11        -c -o GUI.o GUI.cpp
g++      -std=c++11        -c -o Simple_window.o Simple_window.cpp
g++      -std=c++11        -c -o Window.o Window.cpp
g++      -std=c++11        -lfltk -lfltk_images  sample_main4.cpp Graph.o GUI.o Simple_window.o Window.o

/tmp/ccshmUhR.o: In function `Graph_lib::Window::~Window()':
sample_main4.cpp:(.text._ZN9Graph_lib6WindowD2Ev[_ZN9Graph_lib6WindowD5Ev]+0x31): undefined reference to `Fl_Window::~Fl_Window()'
/tmp/ccshmUhR.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x28): undefined reference to `Fl_Window::handle(int)'
/tmp/ccshmUhR.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x30): undefined reference to `Fl_Window::resize(int, int, int, int)'
/tmp/ccshmUhR.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x38): undefined reference to `Fl_Window::show()'
/tmp/ccshmUhR.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x40): undefined reference to `Fl_Window::hide()'
/tmp/ccshmUhR.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x60): undefined reference to `Fl_Window::flush()'
Graph.o: In function `Graph_lib::draw_mark(Point, char)':
Graph.cpp:(.text+0xb9e): undefined reference to `fl_draw(char const*, int, int)'
Graph.o: In function `Graph_lib::Text::draw_lines() const':
Graph.cpp:(.text+0x1223): undefined reference to `fl_draw(char const*, int, int)'
Graph.o: In function `Graph_lib::Image::Image(Point, String, Graph_lib::Suffix::Encoding)':
Graph.cpp:(.text+0x1dbc): undefined reference to `Fl_JPEG_Image::Fl_JPEG_Image(char const*)'
Graph.cpp:(.text+0x1df6): undefined reference to `Fl_GIF_Image::Fl_GIF_Image(char const*)'
Graph.o: In function `Fl_Image::Fl_Image(int, int, int)':
Graph.cpp:(.text._ZN8Fl_ImageC2Eiii[_ZN8Fl_ImageC5Eiii]+0x12): undefined reference to `vtable for Fl_Image'
Graph.o: In function `fl_color(unsigned int)':
Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0xe): undefined reference to `fl_graphics_driver'
Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0x21): undefined reference to `fl_graphics_driver'
Graph.o: In function `fl_color()':
Graph.cpp:(.text._Z8fl_colorv[_Z8fl_colorv]+0x7): undefined reference to `fl_graphics_driver'
Graph.o: In function `fl_line_style(int, int, char*)':
Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x15): undefined reference to `fl_graphics_driver'
Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x26): undefined reference to `fl_graphics_driver'
Graph.o:Graph.cpp:(.text._Z7fl_rectiiii[_Z7fl_rectiiii]+0x17): more undefined references to `fl_graphics_driver' follow
Graph.o: In function `Graph_lib::Bad_image::draw(int, int, int, int, int, int)':
Graph.cpp:(.text._ZN9Graph_lib9Bad_image4drawEiiiiii[_ZN9Graph_lib9Bad_image4drawEiiiiii]+0x2d): undefined reference to `Fl_Image::draw_empty(int, int)'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x20): undefined reference to `Fl_Image::copy(int, int)'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x28): undefined reference to `Fl_Image::color_average(unsigned int, float)'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x30): undefined reference to `Fl_Image::desaturate()'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x38): undefined reference to `Fl_Image::label(Fl_Widget*)'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x40): undefined reference to `Fl_Image::label(Fl_Menu_Item*)'
Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x50): undefined reference to `Fl_Image::uncache()'
Graph.o: In function `Graph_lib::Bad_image::~Bad_image()':
Graph.cpp:(.text._ZN9Graph_lib9Bad_imageD2Ev[_ZN9Graph_lib9Bad_imageD5Ev]+0x20): undefined reference to `Fl_Image::~Fl_Image()'
Graph.o:(.rodata._ZTIN9Graph_lib9Bad_imageE[_ZTIN9Graph_lib9Bad_imageE]+0x10): undefined reference to `typeinfo for Fl_Image'
GUI.o: In function `Graph_lib::Button::attach(Graph_lib::Window&)':
GUI.cpp:(.text+0x5b): undefined reference to `Fl_Button::Fl_Button(int, int, int, int, char const*)'
GUI.o: In function `Graph_lib::In_box::attach(Graph_lib::Window&)':
GUI.cpp:(.text+0x1b3): undefined reference to `Fl_Input::Fl_Input(int, int, int, int, char const*)'
GUI.o: In function `Graph_lib::Out_box::put(String const&)':
GUI.cpp:(.text+0x229): undefined reference to `Fl_Input_::value(char const*)'
GUI.o: In function `Graph_lib::Out_box::attach(Graph_lib::Window&)':
GUI.cpp:(.text+0x291): undefined reference to `Fl_Output::Fl_Output(int, int, int, int, char const*)'
Simple_window.o: In function `Simple_window::wait_for_button()':
Simple_window.cpp:(.text+0x160): undefined reference to `Fl::wait()'
Simple_window.cpp:(.text+0x167): undefined reference to `Fl::redraw()'
Window.o: In function `Graph_lib::Window::Window(int, int, String const&)':
Window.cpp:(.text+0x34): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
Window.cpp:(.text+0x9b): undefined reference to `Fl_Window::~Fl_Window()'
Window.o: In function `Graph_lib::Window::Window(Point, int, int, String const&)':
Window.cpp:(.text+0xf6): undefined reference to `Fl_Window::Fl_Window(int, int, int, int, char const*)'
Window.cpp:(.text+0x15d): undefined reference to `Fl_Window::~Fl_Window()'
Window.o: In function `Graph_lib::Window::draw()':
Window.cpp:(.text+0x1c3): undefined reference to `Fl_Window::draw()'
Window.o: In function `Graph_lib::Window::attach(Graph_lib::Widget&)':
Window.cpp:(.text+0x236): undefined reference to `Fl_Group::begin()'
Window.cpp:(.text+0x260): undefined reference to `Fl_Group::end()'
Window.o: In function `Graph_lib::gui_main()':
Window.cpp:(.text+0x47b): undefined reference to `Fl::run()'
Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x28): undefined reference to `Fl_Window::handle(int)'
Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x30): undefined reference to `Fl_Window::resize(int, int, int, int)'
Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x38): undefined reference to `Fl_Window::show()'
Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x40): undefined reference to `Fl_Window::hide()'
Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x60): undefined reference to `Fl_Window::flush()'
Window.o:(.rodata._ZTIN9Graph_lib6WindowE[_ZTIN9Graph_lib6WindowE]+0x10): undefined reference to `typeinfo for Fl_Window'
collect2: error: ld returned 1 exit status
makefile:25: recipe for target 'main' failed
make: *** [main] Error 1

这是我的制作文件:

CC     = g++     # the c compiler to use
DFLAGS = -std=c++11       # common defines
FLTK   = -lfltk -lfltk_images   # fltk defines

all: main

clean:
        rm -f *.o

# ==== FLTK LIBRARY ====
Graph.o: Graph.cpp
        $(CC) $(DFLAGS) -c -o $@ $<

GUI.o: GUI.cpp
        $(CC) $(DFLAGS) -c -o $@ $<

Simple_window.o: Simple_window.cpp
        $(CC) $(DFLAGS) -c -o $@ $<

Window.o: Window.cpp
        $(CC) $(DFLAGS) -c -o $@ $<

# ==== MAIN FILE ====
main: Graph.o GUI.o Simple_window.o Window.o
        $(CC) $(DFLAGS) $(FLTK) sample_main4.cpp Graph.o GUI.o 
Simple_window.o Window.o

它应该可以编译,但我不知道我的 ubuntu 中缺少什么,因为它可以在我的学校服务器上运行,但不能在我的服务器上运行。所有文件都在两台服务器上的确切位置。

相关内容