Using GLEW in XCode 6- how to set it up? - xcode

The following line gives an error on my Mac.
#include <gl/glew.h>
I have linked the OpenGL and GLUT frameworks already. How can I link/make GLEW available?

Related

Calling OpenGL functions in SDL project causing it to not compile under OSX

I am using SDL2 (latest OSX binaries), C++ and OpenGL in Xcode 8.3.2. The project builds nicely if I am just calling SDL2 functions from the code. However when I include any OpenGL function call in the code it fails to compile. I have already included <OpenGL/gl3.h> in the file header. But I am getting the following error during compilation whenever I invoke any OpenGL method in the code:
Relevant code:
in Display.h:
#ifndef Display_h
#define Display_h
#include <iostream>
#include <SDL2/SDL.h>
#include <OpenGL/gl3.h>
...
in Display.cpp:
void Display::Clear(float r, float g, float b, float a)
{
glClearColor(r,g,b,a);
}
I am running OSX 10.12
Problem's been solved. I needed to add the OpenGL framework under "Build Phases" > "Link Binary With Libraries" of the project. I already did that for SDL2. But didn't know that I need to do the same for OpenGL too.

GLUT on Mac misses mUI

I'm trying to recompile an older unix OpenGL program on the mac. I came to the moment when most of dependencies are fulfilled. However, now I'm stuck on mUI extension of GLUT. I checked on my linux machine and there is a whole directory lib/mui with sources and include/mui with headers in glut-3.7. After compiling on linux I ended up with library files libglut.so.3.7 and libmui.a. The later one I linked to my program. I have found no trace of mui in GLUT.framework (OSX 10.9, Xcode 6.2; gcc/gfortran 5.0). Has anybody idea how to deal with this problem. I'm a bit afraid to compile glut myself, as I have no idea what will happen to my build if two different GLUTs exist. Should I just compile glut3.7 and statically link my code to this library?
In the end I have compiled the libmui.a file using sources from glut-3.7.
I adapted the make file for linux. The main change was replacing OpenGL and Glut libraries to frameworks:
LIBRARIES = -framework glui -framework glut -framework OpenGL -lXmu -lXext -lX11 -lm
In *.C files I have replaced call to GLUT with:
#ifdef __APPLE__
#include <GLUT/glut.h>
#elif
#include <GL/glut.h>
#endif
That was. I linked the libmui.a to my elderly application and it worked without any trouble.

How can I change an OpenGL source code file?

I have an OpenGL file called wglew.h which I downloaded from http://glew.sourceforge.net/. Using the wglew.h as I downloaded it, I receive the following error when compiling a program that I have (I am using MacOSX):
/Users/Downloads/glew-1.11.0/include/GL/wglew.h:70:10: fatal error:'windows.h' file not found
I am trying to go back into the source code of that file and change its dependency from windows.h to something that my Mac could recognize. The source code snippet in the wglew.h file is:
#if !defined(WINAPI)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
#include <windows.h>
# undef WIN32_LEAN_AND_MEAN
#endif
Is it possible to work around this windows.h dependency so that my program does not error out at this step? I asked a similar, but not identical question about a parallel concept at: Where can I get windows.h for Mac? Perhaps instead of looking for an equivalent windows.h file (if such exists for the Mac), I can try to devise a more subtle approach of changing the source code within the wglew.h file to get my program to work and accommodate the windows dependency that I am experiencing?
Here we go again: GLEW is not part of OpenGL. It's a third party library.
You don't need GLEW on MacOS X !
You're barking up the wrong tree!
Instead of trying to fix GLEW (which you don't have to). Just fix your program to not use GLEW when being compiled for MacOS X.
Everywhere in your program where you find a
#include <glew.h>
or
#include <GL/glew.h>
Change it into
#ifndef __APPLE__
#include <GL/glew.h>
#else
#include <OpenGL/gl.h>
#endif/*__APPLE__*/
Put any occurance where a GLEW function is called between a
#ifndef __APPLE__
…
#endif/*__APPLE__*/
block as well.
You don't need GLEW on MacOS X ! Don't use it there.

include GLUT in qt project with cmake

I'm trying to do a cmake project with opengl and qt.
this is the cmake where I include opengl:
# opengl
set(QT_USE_QTOPENGL TRUE)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
set(OPENGL_LIBS ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
And it found them, this is a part of cmake output:
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- Found GLUT: -framework GLUT
And I can include OpenGL with this:
#include <QtOpenGL>
with this it finds correctly gl* glGetString(GL_VENDOR) or glGetString(GL_VERSION) and they works.
BUT I'm not able to include GLUT includes.
I'm on Mac OSX 10.8.4, Qt 4.8, QtCreator 2.7.1 and Opengl 2.1
Please note that the same cmake file under Ubuntu 12.04 let me include GL/gl.h and GL/glut.h correctly.
BUT I'm not able to include GLUT includes.
Why would you want to use GLUT when you're already using Qt?
GLUT is a framework for window creation and event loop processing.
Qt is a framework for window creation and event loop processing.
You can't (well, should not) have two framework within the same program doing the exact same thing (unless you're interested in seeing them fighting some battle over the same resources).
On OSX you need to include GLUT/glut.h, so write something like that in your code:
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

Xcode Intel compiler icc cannot find #include <algorithm>

Hi I'm trying to compile a gcc based code on Xcode with the icc compiler (11.1.088)
but i have the following error:
catastrophic error: could not open source file "algorithm"
After looking to this file, it is located in the gcc include directory, but i get hundreds of errors...
Does anyone have suggestions ?
Thanks.
I was having a really stubborn error very similar to this question but with a different solution.
Algorithm: No such file or directory
My solution:
#ifdef __cplusplus
#include <algorithm>
#endif
I had the #include in a prefix header file (such as the .pch file Xcode gives you in a new project) which was causing it to be included in an Objective-C file, and apparently algorithm is C++ only. Either make sure all your Objective-C files are Objective-C++ (.mm) or add that directive to make sure it doesn't get included in those files.
What do you have set as your base SDK ? And what version of Xcode ?
FWIW I just tried a test with Xcode 3.2.3 and ICC 11.1 (under OS X 10.6 of course) - created a new C++ console application using the standard Xcode template, added #include <algorithm> to main.cc, switched from the default gcc 4.2 to ICC, and it compiles and runs without warnings or errors. The base SDK is the system default (10.6).
It may just be that you have a bad installation of Xcode and/or ICC, or perhaps you have changed a project setting such as base SDK, and this is causing problems.
This problem occurred on my machine, while developing an iOS app.
Xcode Version 4.6.3 (4H1503) & iOS version 6.0
I'm using AppCode for development and the IDE added (by accident) the following import statement:
#import <c++/4.2.1/ext/algorithm>
I met this error too, I just forget to change the source from .m to .mm. so, if adjust C++ complier cannot work, try to change the source file.

Resources