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
Related
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.
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?
I'm trying to link OpenGL to my Qt .pro file. I've installed the SDL Library properly and this is my .pro file :
QT += opengl
INCLUDEPATH += /Library/Frameworks/SDL.framework/Versions/A/Headers
LIBS += -framework Cocoa -framework SDL
LIBS += -F/Library/Frameworks
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
HEADERS += \
SDLMain.h
OBJECTIVE_SOURCES += \
SDLMain.m
The problem is that #include <GL/gl.h> and #include <GL/glu.h> are still not find by the QtCreator. The error message is:
/Users/Anass/testsdl/main.cpp:42: erreur : 'GL/glu.h' file not found
Can you help me ?
Well, you have to add the OpenGL framework as well if you want to use OpenGL.
These are not the correct header file names on Mac OS:
#include <GL/gl.h>
#include <GL/glu.h>
On Mac OS, for headers that are part of a framework, the first part of the include file name is the name of the framework. This is OpenGL in this case. Therefore, the include statements need to be:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
Also make sure that you link the OpenGL framework by adding -framework OpenGL to the link options.
OS X 10.6.8, XCode 3.2.6, Base SDK 10.5, Intel Compiler 11.1
I am getting a weird message when I try to compile that says:
catastrophic error: could not open source file "stdarg.h"
I am using a PCH, I did find: Xcode Intel compiler icc cannot find #include <algorithm>
which is a similar issue and I think that the source file type is set to .c.c instead of .c
From what I can see stdarg.h is:
/* This file is public domain. */
/* GCC uses its own copy of this header */
#if defined(__GNUC__)
#include_next <stdarg.h>
#elif defined(__MWERKS__)
#include "mw_stdarg.h"
#else
#error "This header only supports __MWERKS__."
#endif
so must be GNUC is defined, obviously.
Can anyone help me figure out how to better compile since this works without changes in GCC 4.0? Is there a global way one might have XCode re-evaluate the source file type to not be .c.c or .cpp.cpp I am not even sure how this would happen.
Also, is there a #define that I can check to see if the Intel compilers are being used to make special cases if I need to?
I looked at a few of the files referenced in the build results and looking at the source file type in XCode it says source.c.c and I think if I change that to source.c that compiler error goes away.
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.