Linux上的OpenGL库链接 [英] OpenGL libraries linkage on linux
问题描述
我编写了一个小OpenGL程序,显示了一个简单的四边形.为了完成这项工作,我在我的Makefile中链接了-lglut.直到这里一切都好.
I coded a small OpenGL program displaying a simple quad. To do the job done, I linked -lglut in my Makefile. Until here all is ok.
这是我的Makefile内容:
Here's my Makefile content :
NAME = Quad
CXX = g++
SRCS = main.cpp
OBJS = $(SRCS:.cpp=.o)
CXXFLAGS += -W -Werror -Wextra
LIBX += -lglut
RM = rm -f
all : $(NAME)
$(NAME) : $(OBJS)
$(CXX) -o $(NAME) $(OBJS) $(LIBX)
clean :
find . \( -name "*.o" -o -name "*~" -o -name "#*#" \) -exec $(RM) {} \;
fclean : clean
$(RM) $(NAME)
re : fclean all
.PHONY : all \
clean \
fclean \
re
但是现在我想与我自己的库资源文件建立链接. 这是我的项目目录的内容:
But now I want to make a linkage with my own librairies resources files. Here's the content of my project directory :
main.cpp
Makefile
Outbuilding/GL/include/glut.h
Outbuilding/GL/lib/glut32.lib
我在main.cpp中的包含声明
My include declaration in main.cpp
#include "gl/glut.h"
我试图编辑以下Makefile,但它不起作用(找不到文件gl/glut.h):
I tried to edit the following Makefile but it does not work (the file gl/glut.h is not found) :
NAME = Quad
CXX = g++
SRCS = main.cpp
OBJS = $(SRCS:.cpp=.o)
CXXFLAGS += -W -Werror -Wextra
INCLUDE += -I./Outbuilding/GL/include -L./Outbuilding/GL/lib
LIBX += -lglut
RM = rm -f
all : $(NAME)
$(NAME) : $(OBJS)
$(CXX) -o $(NAME) $(OBJS) $(INCLUDE) $(LIBX)
clean :
find . \( -name "*.o" -o -name "*~" -o -name "#*#" \) -exec $(RM) {} \;
fclean : clean
$(RM) $(NAME)
re : fclean all
.PHONY : all \
clean \
fclean \
re
我也尝试在源文件中直接链接glut.h(#include"./Outbuilding/GL/include/gl/glut.h"),但出现以下错误:
I also tried in my source file to link directly glut.h (#include "./Outbuilding/GL/include/gl/glut.h") but I have the following error :
error : "APIENTRY" redefined
有人可以帮助我吗?
推荐答案
您的 glut.h 文件位于错误的文件夹中.
Your glut.h file is in the wrong folder.
通常 glut.h 是一个 gl 文件夹,在您的项目中是全局文件夹或本地文件夹.
Normally glut.h is a gl folder, either global or local to your project.
只需在 Outbuilding/GL/include/中创建一个名为* gl8的文件夹,然后将 glut.h 移入其中.
Just create a folder called *gl8 inside Outbuilding/GL/include/ and move the glut.h into it.
这篇关于Linux上的OpenGL库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!