Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
941 views
in Technique[技术] by (71.8m points)

macos - Compiling a C program that uses OpenGl in Mac OS X

I am trying to compile a C program for my CS class. I have Command Line tools installed on my Mac, so I probably have OpenGL. The program description was made for Ubuntu and it says for me to compile using:

gcc -Wall -ansi -pedantic -O2 main.o graphic.o imagem.o io.o -o ep2 -lGL -lGLU -lglut

I ran that and it said:

ld: library not found for -lGL

What flags should I use? What do I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In MacOS X you're not using libraries to include system level APIs, but Frameworks. The proper command line to compile this program would be

gcc -Wall -ansi -pedantic -O2 
    main.o graphic.o imagem.o io.o 
    -o ep2 
    -framework OpenGL -lGLU -lglut

Note that GLU is probably part of the OpenGL framework as well. And it may be required to install GLUT first.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...