Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aresti

macrumors newbie
Original poster
Jun 17, 2008
7
0
Hi, I am confused..,
-Does Opengl api is installed on leopard alredy. If not, how can i install it
-How can I create c++ aplications, I dont want nothing with carbon or objetive c, because i want my aplication to be portable to windows and linux
 

autorelease

macrumors regular
Oct 13, 2008
144
0
Achewood, CA
Yes, Mac OS X provides OpenGL libraries and headers.

Install the Developer Tools if you haven't done so. You can use Xcode to create plain C++ projects using the OpenGL framework.

You can also forgo Xcode completely and use a plain Makefile and a text editor, just like you would on Linux. This will make cross-platform compatibility with Linux (and Windows, with a little tweaking) trivial. If you decide not to use Xcode, add the following to your CFLAGS and LDFLAGS in your Makefile:

-framework GLUT -framework OpenGL -framework Cocoa

This assumes you want to use GLUT. If you really want cross-platform compatibility, and support for sound, joysticks, etc. consider using SDL instead (http://www.libsdl.org). They have a Mac framework available.
 

Aresti

macrumors newbie
Original poster
Jun 17, 2008
7
0
Hi, When i go to to frameworks on xcode, I only saw carbon framework and cocoa framework, where is opengl framework?
I created a c++ project and it says it cant find glut, When i create a Carbon projet it seems to work but i dont want to do it with carbon because i want it to be portable
Code:
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

// A simple OpenGL and glut program 
#include <GL/gl.h> 
#include <GL/glut.h> 
void display() { 
glClear(GL_COLOR_BUFFER_BIT); 
glFlush(); 
} 
int main(int argc, char **argv) { 
glutInit(&argc, argv); 
glutInitWindowSize(512,512); 
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 
glutCreateWindow("The glut hello world program"); 
glutDisplayFunc(display); 
glClearColor(0.0, 0.0, 0.0, 1.0); 
glutMainLoop(); // Infinite event loop 
return 0; 
}
 

Aresti

macrumors newbie
Original poster
Jun 17, 2008
7
0
Hi, When i go to to frameworks on xcode, I only saw carbon framework and cocoa framework, where is opengl framework?
I created a c++ project and it says it cant find glut, When i create a Carbon projet it seems to work but i dont want to do it with carbon because i want it to be portable
Also, if it works with the carbon framework, it should work on a opengl windows with minimal changes.., doesnt it? I have been testing opengl with the Carbon framwork, but i have a linking error g++-4.0 failed with exit code 1
below is the code
Code:
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

// A simple OpenGL and glut program 
#include <GL/gl.h> 
#include <GL/glut.h> 
void display() { 
glClear(GL_COLOR_BUFFER_BIT); 
glFlush(); 
} 
int main(int argc, char **argv) { 
glutInit(&argc, argv); 
glutInitWindowSize(512,512); 
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 
glutCreateWindow("The glut hello world program"); 
glutDisplayFunc(display); 
glClearColor(0.0, 0.0, 0.0, 1.0); 
glutMainLoop(); // Infinite event loop 
return 0; 
}
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
You have to add additional frameworks - right click on Frameworks -> Add -> Existing Frameworks ...

Edit: I'm not clear on how you want this to be portable - you can build and test your app on a Mac using XCode, but the executable won't run in Windows or Linux. You'll need to build the executable on the target machines, and to do that you'll need to create your own Make files... well on Linux you will. I don't know how you'd do it on windows unless you install cygwin.

So I would avoid XCode if I were you.

I suggest you look at some cross-platform source code, e.g. Apache, to see how they handle this.

Edit 2: and what autorelease said.
 

Aresti

macrumors newbie
Original poster
Jun 17, 2008
7
0
Well, where does it says frameworks exactly, If you are referring to the frameworks when I clik new project, I cant click on it because nothing happens...,
My linking error:

Ld "/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/Debug/prueba.app/Contents/MacOS/prueba" normal i386
cd "/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba"
/Developer/usr/bin/g++-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk "-L/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/Debug" "-F/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/Debug" -Fopengl -filelist "/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/prueba.build/Debug/prueba.build/Objects-normal/i386/prueba.LinkFileList" -mmacosx-version-min=10.5 -framework Carbon -o "/Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/Debug/prueba.app/Contents/MacOS/prueba"
ld: duplicate symbol _main in /Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/prueba.build/Debug/prueba.build/Objects-normal/i386/main-20353861.o and /Users/Sebastian/Universidad/Objetos y Abstraccion/prueba/build/prueba.build/Debug/prueba.build/Objects-normal/i386/main-A07497A6.o
collect2: ld returned 1 exit status
 

Aresti

macrumors newbie
Original poster
Jun 17, 2008
7
0
I found the framework, I added but I keep getting errors, anyways when I used the carbon template with opengl, i dont get any error but i get that linking error above. Maybe i need to modify project settings?

Here are the error i get
Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:7:20: error: GL/gl.h: No such file or directory
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:8:22: error: GL/glut.h: No such file or directory
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp: In function 'int main(int, char**)':
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:14: error: 'glutInit' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:15: error: 'glutInitWindowSize' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:16: error: 'GLUT_SINGLE' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:16: error: 'GLUT_RGB' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:16: error: 'glutInitDisplayMode' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:17: error: 'glutCreateWindow' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:18: error: 'glutDisplayFunc' was not declared in this scope
/Users/Sebastian/Universidad/Objetos y Abstraccion/dos/main.cpp:20: error: 'glutMainLoop' was not declared in this scope
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

You're #including the wrong headers. You need:-

Code:
#include <GLUT/glut.h>

The name of the framework excluding the .framework is the the first part of the path to the include. If you look in the framework (in Xcode) you'll see the headers. SO to include glu.h you would use:-

Code:
#include <OpenGL/glu.h>

b e n


b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.