GL_COLOR_BUFFER_BIT and many more show "undeclared identifier by Xcode - opengl

I am trying run Apple documentation sample code, placed on this link...
Sample Code
However when I run this code XCode fails to compile. It shows several error stating that below listed variables are not defined.
GL_COLOR_BUFFER_BIT
GL_VIEWPORT
GL_PROJECTION
GL_MODELVIEW
GL_QUADS
My understanding is, it is obvious that Xcode couldn't fins this const variables and it seems like they are from OpenGL framework. I checked my imported framework list it have OpenGL in it.
How to solve this?
Environment :
OS version : MacOSX 10.7.3
Base SDK of the project : MacOSX SDK 10.7
Compiler : Defualt LLVC GCC 4.2

Just add
#import <OpenGL/gl.h>
to the file NormalGLView.m (at the top of the file, after the other import). That fixed it for me...
The problem was not that it couldn't find the framework, but it couldn't find the definitions, indicating that a header file might be missing

Related

math_functions.hpp not found when using CUDA with Eigen

I have some code that is heavily dependent on Eigen. I would like to optimize it with CUDA, but when I am compiling I get:
[tcai4#golubh4 Try1]$ nvcc conv_parallel.cu -I /home/tcai4/project-cse/Try1 -lfftw3 -o conv.o
In file included from Eigen/Dense:1,
from Eigen/Eigen:1,
from functions.h:8,
from conv_parallel.cu:10:
Eigen/Core:44:34: error: math_functions.hpp: No such file or directory
I think math_functions.hpp is a file from CUDA. Can someone help me figure out why nvcc cannot find it?
edit: I am using CUDA 5.5 and Eigen 3.3, except from linking Eigen and fftw3 library, I did not use any other flags(as you can see from my code).
I encountered this issue while building TensorFlow 1.4.1 with Cuda 9.1, and strangely math_functions.hpp existed only in include/crt.
Creating a symlink from cuda/include/math_functions.hpp to cuda/include/crt/math_functions.hpp fixed the issue:
ln -s /usr/local/cuda/include/crt/math_functions.hpp /usr/local/cuda/include/math_functions.hpp
The reason nvcc cannot find the file in question is because that file is part of the CUDA Math library, which was introduced in CUDA 6. Your almost 4 year old version of CUDA predates the release of the Math library. Your CUDA version doesn't contain said file.
You should, therefore, assume that what you are trying to do cannot work without first updating to a newer version of the CUDA toolkit.
Creating symlink sometimes causes other complication.
You can try replacing
// We need math_functions.hpp to ensure that that EIGEN_USING_STD_MATH macro
// works properly on the device side
#include <math_functions.hpp>
with
// We need cuda_runtime.h to ensure that that EIGEN_USING_STD_MATH macro
// works properly on the device side
#include <cuda_runtime.h>
in
/usr/include/eigen3/Eigen/Core,
which works for me.
The reason why "math_functions.hpp" cannot be found is because "math_functions.hpp" has been renamed to "math_functions.h". So you just need to go to
/usr/include/eigen3/Eigen/Core
and change "math_functions.hpp" to "math_functions.h"

Compiling OpenCV2.8 with OpenCL1.1

I tried compiling OpenCV 2.4.13.1 with opencl 1.1 with headers from https://github.com/KhronosGroup/OpenCL-Headers
I had to change #ifdef CL_VERSION_1_2 to #ifdef CL_VERSION_1_1 in opencv/cmake/checks/opencl.cpp
also http://docs.opencv.org/2.4.13/modules/ocl/doc/introduction.html suggests that it should work with OpenCL 1.1
But I still get errors like cl_runtime_opencl.hpp:294:61: error: 'cl_device_partition_property' does not name a type when building.
Do I have to go back to an older version to get OpenCL1.1 working? or have I missed something?
Edit:
I don't mind an answer for OpenCV 3.0

GLEW_APPLE_GLX Causes Linking Error When Building GLEW

I grepped inside GLEW while trying to solve my other question, concerning missing __glewX* symbols for Mac, and found that they are guarded by GLEW_APPLE_GLX.
When I attempt to build GLEW from source with that flag defined, I get undefined symbols (stuff like _glXGetClientString). Linking against X11 (-lX11) doesn't help.
Question: assuming defining GLEW_APPLE_GLX does indeed make sense, how can I fix the build?
When building an application that uses the X Server (XQuartz) instead of using CGL, you also need to add -lGL.
Ordinarily when building GL software on OS X you use OpenGL.framework (-framework OpenGL) and that gets you OpenGL and CGL/AGL functions but leaves out GLX.
You should also ditch any includes to things like <OpenGL/gl.h> and use <GL/gl.h> instead, as that will point to /usr/X11R6/include/GL/... instead of the OpenGL framework headers.

D glGenVertexArrays without GLEW

I want to fully use OpenGL 3.3 in my program, but glGenVertexArrays segfaults without some special initialization. I've looked at the GLEW source but couldn't find what is done for it to work.
I tried binding to GLEW, but OPTLINK either says the library is invalid (when compiled with VS2012) or the symbol is not found (uint glewInit() in a MinGW dll converted to lib with implib).
If there are only a few lines needed doing what GLEW does (I suppose I don't need 1000 lines of function getting) I would like to do that myself, when it's too much I would appreciate some help on building a lib that D actually accepts.
This is a good start : http://www.opengl.org/wiki/Load_OpenGL_Functions
Follow the links to The OpenGL Registry : http://www.opengl.org/registry/
Here you can find useful header files for your platform. I would recommend using GLEW or similar libs though.

Debugging SFML Project in Xcode - Install to Blame?

I followed the instructions to set up SFML here. When I check my /Library/Frameworks folder, all the SFML stuff seems to be there. However, when I check out a project my group is working on using SFML, and when I build, I get a ton of errors. These errors do not exist for my other group members. I think (some of) my errors are caused by SFML not recognizing sf::Input as a type.
Here is my code for one of the header classes in my project:
#pragma once
#include "Mover.h"
class InputMover : public Mover
{
public:
InputMover(const sf::Input* pInput);
//error here - expected unqualified-id before * token
protected:
const sf::Input* m_pInput;
//error here - ISO C++ forbids declaration of Input with no type
};
The parts without errors have been taken out. What do you think the problem is?
EDIT, SOLVED:
The problem was that I installed SFML with makefiles before I just did a copy-install. Some files were conflicting. I tracked down the installed files and deleted them. This seemed to fix the problem.
To use the SFML classes you need to include their definitions.
Add #include <SFML/Window/Input.hpp> to the top of your file.
Also note that to use SFML you must also link to the CoreFoundation, Cocoa and OpenGL frameworks, as well as to libfreetype.