I am trying to develop OpenGL programs with C++ on Mac using Netbeans, and there are some compilation errors:
“/usr/bin/make” -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
“/usr/bin/make” -f nbproject/Makefile-Release.mk dist/Release/GNU-MacOSX/sdl_test
mkdir -p build/Release/GNU-MacOSX
rm -f build/Release/GNU-MacOSX/main.o.d
g++ -c -O2 -MMD -MP -MF build/Release/GNU-MacOSX/main.o.d -o build/Release/GNU-MacOSX/main.o main.cpp
main.cpp:9:41: warning: OpenGL.framework/Headers/gl.h: No such file or directory
my code is as simple as this:
#include <iostream>
#include <OpenGL.framework/Headers/gl.h>
/*
*
*/
int main(int argc, char** argv) {
std::cout << glGetString(GL_VERSION) << std::endl;
return 0;
}
the compiler cannot find OpenGL header file even if I have added the including path and lib file in the project settings. This is really confusing..
In your project properties go to
C++ Compiler. UnderInclude Directoriesadd/System/Library/Frameworks. UnderLinkerat the bottom underAdditional Optionsadd-framework OpenGL.Change your include directive to
#include <OpenGL/gl.h>Now you should be able to compile your program. But I seem to be missing something, because I get a segmentation fault, when I call
glGetString…