FLTK的编译错误:对“Fl_Menu_Bar”和“Fl_Int_Input”的未定义引用

时间:2016-01-30 23:53:38

标签: ubuntu-12.04 fltk

我已经在我的Ubuntu 12.04系统中安装了FLTK1.3。

sudo apt-get install libfltk1.3-dev
sudo apt-get install libx11-dev

我正在尝试使用FLTK构建一个计算机图形项目,但是会出现一些错误。

$ make
g++ -g -fpermissive -std=c++11 -o trace src/main.o src/getopt.o src/RayTracer.o src/ui/CommandLineUI.o src/ui/GraphicalUI.o src/ui/TraceGLWindow.o src/ui/debuggingView.o src/ui/glObjects.o src/ui/debuggingWindow.o src/ui/ModelerCamera.o src/fileio/imageio.o src/fileio/buffer.o src/parser/Token.o src/parser/Tokenizer.o src/parser/Parser.o src/parser/ParserException.o src/scene/camera.o src/scene/light.o src/scene/material.o src/scene/ray.o src/scene/scene.o src/SceneObjects/Box.o src/SceneObjects/Cone.o src/SceneObjects/Cylinder.o src/SceneObjects/trimesh.o src/SceneObjects/Sphere.o src/SceneObjects/Square.o src/threads/ThreadPool.o -I/usr/local/include/ -I/usr/local/lib/ -I/png -I/jpeg -L/usr/local/lib/libfltk.a -L/usr/lib/gcc/x86_64-linux-gnu/4.6/  -lfltk -lfltk_gl  -lfltk_images -lfltk_forms -lXext -lX11 -lm -lGL -lGLU -lpng -ljpeg -lz   -lXfixes -lpthread -lfontconfig -lXcursor -lXt -ldl  /usr/lib/x86_64-linux-gnu/libfltk.so
src/ui/GraphicalUI.o: In function `GraphicalUI':
/media/sda6/swagatika/Documents/project2_trace/trace/src/ui/GraphicalUI.cpp:343: undefined reference to `Fl_Menu_Bar::Fl_Menu_Bar(int, int, int, int, char const*)'
src/ui/GraphicalUI.o: In function `Dialog2::getValue()':
/media/sda6/swagatika/Documents/project2_trace/trace/src/ui/dialog.h:26: undefined reference to `Fl_Int_Input::Fl_Int_Input(int, int, int, int, char const*)'
src/ui/debuggingWindow.o: In function `DebuggingWindow':
/media/sda6/swagatika/Documents/project2_trace/trace/src/ui/debuggingWindow.cxx:216: undefined reference to `Fl_Menu_Bar::Fl_Menu_Bar(int, int, int, int, char const*)'
collect2: error: ld returned 1 exit status
make: *** [trace] Error 1

有什么线索会发生错误?

这两个标题文件存在于/usr/local/include/FL/中,并包含在源文件中。

/usr/local/include/FL/Fl_Menu_Bar.H /usr/local/include/FL/Fl_Int_Input.H

如果它有帮助,我有关于fltk-config

的以下信息
$ fltk-config --cflags --libs
-I/usr/local/include -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT
/usr/local/lib/libfltk.a

$ fltk-config --ldflags --use-gl
-L/usr/local/lib -lfltk_gl -lGLU -lGL -lfltk -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11

如果你想查看Makefile:

#
#  Makefile for fltk applications
#

# set local paths
FLTK =

#INCLUDE = -I$(FLTK) -I$(FLTK)/png -I$(FLTK)/jpeg
#LIBDIR = -L$(FLTK)/lib
#LIBDIR = -L/usr/lib/x86_64-linux-gnu/
LIBDIR = -L/usr/local/lib/libfltk.a

INCLUDE =  -I/usr/local/include/ -I/usr/local/lib/ -I$(FLTK)/png -I$(FLTK)/jpeg

#LIBS = -lfltk -lfltk_gl -lXext -lX11 -lm -lGL -lGLU -lpng -ljpeg -lz -ldl -lXfixes -lpthread
LIBS =  -L/usr/lib/gcc/x86_64-linux-gnu/4.6/  -lfltk -lfltk_gl  -lfltk_images -lfltk_forms -lXext -lX11 -lm -lGL -lGLU -lpng -ljpeg -lz   -lXfixes -lpthread -lfontconfig -lXcursor -lXt -ldl 

CFLAGS = -g -fpermissive -std=c++11

CC = g++

.SUFFIXES: .o .cpp .cxx

.cpp.o: 
    $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $<

.cxx.o: 
    $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $<

ALL.O = src/main.o src/getopt.o src/RayTracer.o \
    src/ui/CommandLineUI.o src/ui/GraphicalUI.o src/ui/TraceGLWindow.o \
    src/ui/debuggingView.o src/ui/glObjects.o src/ui/debuggingWindow.o \
    src/ui/ModelerCamera.o \
    src/fileio/imageio.o src/fileio/buffer.o \
    src/parser/Token.o src/parser/Tokenizer.o \
    src/parser/Parser.o src/parser/ParserException.o \
    src/scene/camera.o src/scene/light.o \
    src/scene/material.o src/scene/ray.o src/scene/scene.o \
    src/SceneObjects/Box.o src/SceneObjects/Cone.o \
    src/SceneObjects/Cylinder.o src/SceneObjects/trimesh.o \
    src/SceneObjects/Sphere.o src/SceneObjects/Square.o src/threads/ThreadPool.o

trace: $(ALL.O)
    $(CC) $(CFLAGS) -o $@ $(ALL.O) $(INCLUDE) $(LIBDIR) $(LIBS)

clean:
    rm -f $(ALL.O) trace

1 个答案:

答案 0 :(得分:0)

它抱怨链接:不是编译。

LIBDIR应该是一个目录:不是库

LIBDIR = -L/usr/local/lib