1

我刚刚发现了 FLTK,并为我的测试制作了一个 makefile。这是我的生成文件:


################ template makefile ##############
# We don't know what compiler to use to build fltk on this machine - but fltk-config does...
CC  = $(shell fltk-config --cc)
CXX = $(shell fltk-config --cxx)

# Set the flags for compiler: fltk-config knows the basic settings, then we can add our own...
CFLAGS   = $(shell fltk-config --cflags)
CXXFLAGS = $(shell fltk-config --cxxflags) -I/System/Library/Frameworks/OpenGL.framework/Versions/A/

# We don't know what libraries to link with: fltk-config does...
LINKFLTK = $(shell fltk-config --ldstaticflags)
LINKFLTK_GL = $(shell fltk-config --use-gl --ldstaticflags) -lGLU
LINKFLTK_IMG = $(shell fltk-config --use-images --ldstaticflags)

# Possible steps to run after linking...
STRIP      = strip
POSTBUILD  = fltk-config --post # Required on OSX, does nothing on other platforms, so safe to call
TARGET     = CompletedFile

# Define what your target application is called
all: $(TARGET)

# Define how to build the various object files... -snip-

# Now define how to link the final app - let's assume it needs image and OpenGL support
$(TARGET): MyWindow.o main.o 
        $(CXX) -o $@ MyWindow.o main.o  $(LINKFLTK_IMG) $(LINKFLTK_GL)
        $(STRIP) $@
        $(POSTBUILD) $@  # only required on OSX, but call it anyway for portability

############### end #################

(这是目标文件代码:)

main.o: main.cpp MyWindow.h main.h 
        $(CXX) -c $< \
            $(CXXFLAGS)

MyWindow.o: MyWindow.cpp MyWindow.h $(CXX) -c $< \ $(CXXFLAGS)

这是它给我的错误:
在 MyWindow.cpp:10 包含的文件中:
MyWindow.h:14:20:错误:GL/glu.h:没有这样的文件或目录
MyWindow.cpp:在成员函数'virtual void MyWindow::draw()'中:
MyWindow.cpp:49:错误:未在此范围内声明“gluPerspective”
制作:* [MyWindow.o] 错误 1
(代码无关)

4

2 回答 2

1

根据您使用的 fltk 版本,它有一些自己的 openGL 标头。我将以下行添加到我的包含库中: -lfltk -lfltk_gl -lGL -lGLU

矫枉过正,但它完成了工作。

于 2011-03-25T17:14:16.593 回答
0

编译器找不到你的GLU.h头文件。调整您的#include-I开关以指向正确的位置。

于 2011-02-06T06:42:57.290 回答