Adding an OpenGL framework in Xcode 4 - c++

I'm using Xcode 4 for my C++ programming. I want to add a framework, specifically an OpenGL framework, and I'm not quite used to where things are yet. It says in the help documentation that I should select the target, and from there I get the summery pane where I can add a linked framework/library. When I do that, the summery pane doesn't show up. It does show up when my target is a cocoa application, but since I'm programming in C++, I choose the command line tool, and select the language from there. So, how exactly do I add the OpenGL framework to my target?

maybe go under "build phases" (instead of "summary") and then click "Link Binary With Libraries" and add button then search OpenGL.framework
im not sure 100%, im new to this too :)

The easiest way is to go to your project settings, and under Linking -> Other Linking Flags add:
-framework OpenGL

In your project, create a group 'frameworks' (not really necessary but keeps things organized)
With Finder goto: /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks
Locate the OpenGL.framework folder
Drag and drop the folder into your XCode project (in the frameworks group)
Don't copy the files(!)
Probably you want to copy 'GLUT.framework' as well.

Related

Xcode & C/C++ project

I want to use Xcode for C/C++ project.
I don't care about build/compilation, all i want is to use it as editor.
Needs:
- Find symobol , References , callers etc
I've opened a console project, i can search for a symbol in the same file but nothing else. (for example, right click + jump to definition gives me a question mark ('?').
Any pointer to what needs to be done ?
Thanks,
Shaul.
From my experience, XCode is not designed to work well with C++. For example, you'll find that simple refactoring, such as renaming a function and automatically renaming usages, doesn't work well with XCode. I find AppCode works a lot better for (Obj)C++ development. Worth a look.
Thare are two approches
You need to create a library of your c++ project and add that library in your project
Add C++ project in your xcode and make it build as target source
let me now if you need a walkthrough
Ok, I found the solution.
When adding files to the Xcode project, on the bottom , need to click 'Options' and then choose 'Create groups' instead 'Create folder references'
This options will add all the sources and headers to 'Compile sources' and 'Headers' (Under 'Build Phases')

No syntax highlighting with SFML in Code::Blocks?

As I learned C++ using Code:Blocks, I'd love to keep this one as my IDE, but I recently started using "SFML" and Code::Blocks does not seem to recognize SMFL classes/syntax, as shown in the picture. Is there any fix? (The SMFL itself works perfectly). Also, sorry for my terrible english (still learning it as well...).
Edit : Here's the picture :
If you want to use a graphical library in the C++ Code::Blocks IDE, you have two options: do the set-up manually, or use a pre-formed Code::Blocks project.
I will go over the former, since the latter (using the SFML preset) doesn't work on all machines.
Step 1: Create an Empty Project
When creating a new project, choose the Empty Project preset from the pop-up window.
Step 2: Add the header paths
Go to Build Options/Search Directories. Add the path to the SFML include file.
Step 3: Add the library (lib) paths
Now add the path to the SFML library file (lib).
Step 4: Link your project
Go to Linker Settings/Link libraries. Add the desired sub-libraries (by name, like so: sfml-librarynamehere, for example sfml-graphics).
That should do it. Also, keep in mind SFML provides online documentation for this king of things.

How do I set up OpenGL libraries on a Mac?

I would like to be able to go through a lesson on OpenGL so that I may learn to use OpenGL. This means that I need to be able to compile and run the programs myself, so that I may play around with them and begin making my own OpenGL projects. I can't do this if I can't install and include libraries that the lesson is using. So, I need either:
a lessons with instruction, for OSX, on how to install the libraries
that the lesson uses
a lesson that only teaches with the libraries that come with
OSX (GLUT and OpenGL).
From what I have seen around the web, it appears that GLEW is the most used library with these lessons so instruction on how to install that would be top priority. However, if there is another lesson that uses another library and you know how or have a link on how to set that library up for Mac, I would see that as a helpful answer.
Finally, overall, I would appreciate it if someone could tell me how they have their Mac set up with OpenGL, or point me to a tutorial that works with Macs.
Here are the tutorials I have been looking at:
http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html
http://www.opengl-tutorial.org/
http://www.cprogramming.com/graphics-programming.html
I have been able to get the headers GLUT/GLUT.h and OpenGL/gl.h which I think are OpenGL's main header files so, alternatively, if there is a lesson out there that only relies on these two headers (or any headers in the GLUT.framework or the OpenGL.framework included with OS X Lion) that would work just fine for me.
To install most needed development libraries for os X, install fink and then use fink to install everything else:
Fink
Fink Glew page
As an added bonus here are some GLUT tutorials (although for an older version of Xcode).
I'm not sure this is what you need but i'll give you the basics for running an opengl/glut-based program using Xcode.
Create a new empty project, name it whatever you want
Under the project menu click "New Target"
On the left menu select "Cocoa", then click "Application", name it whatever you want
You should have a new window called "Target 'your-program's-name' info"
Under the tab "Build" scroll all the way down to "GCC_PREFIX_HEADER", double click the value (wich should be something like "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h", delete this line, click ok.
Close the info window
Right click your project's name, click Add > Existing frameworks > Select "OpenGL.framework", click add.
Again, right click your project's name, click Add > Existing frameworks > Select "GLUT.framework", click add.
Right click your project's name, click Add > New File > under the "C and C++" tab, select C++ file, click next, name it whatever you want. (make sure it's being added to your project and target), click finish.
You're now ready to build and run any c++ project using OpenGl.framework and GLUT.framework
-You can use command + enter for building and running and command + shift + enter for closing an active window.
-When you require input from the user you should run it from terminal, compile like this:
"gcc -o func2d func2d.c -framework carbon -framework OpenGL -framework GLUT"
where func2d is the name of your application executable and func2d.c is the c file used
The imports required in case you don't have them are:
OpenGL/gl.h
OpenGL/glu.h
GLUT/glut.h
stdlib.h

Eclipse CDT - new template or "project type"

Using Eclipse Helios and CDT 7.
Is it possible to save a project as a new template/project type?
When you go to create a new project, a dialog opens and you select a project type (Executable -> empty project, etc.) I would like to add one.
Point is, I'm playing with SDL, and I know I'll be making a lot of new projects. I don't want to have to go into the preferences each time and set up the compiler/linker to find the files.
I've been looking for a while, but have had no luck finding anything.
Yes you can do what you want. Check out the link How to Register Templates. I created the following plugin using the instructions in the previous link. Download Plugin.

Beginner questions regarding to "building a library", in Xcode on iPhone specifically

I have never been clearly understand all these linking/building/dependency business. Now, I am trying to build the FreeType library (which is in C++), into the *.a library file for the iPhone (because another library I am trying to use, openFrameworks, would depend on FreeType).
I know that to compile C++ with iPhone I simply need to rename *.cpp to *.mm. (I have tried with some simply programs in main() and it works) But how can I build the library in Xcode then ? (without the main() I suppose)
On the other hand, it would be great if you guys could recommend some books or documents on such linking/building topics, which I found myself most confused about.
PS. I have already got the paid version of Xcode and some sample apps compiled onto the iPhone.
Renaming .cpp files to .mm would mean they'll be treated as Objective-C++ code rather than C++ code. I don't think that'd be a good idea, even if it should still work. Besides, FreeType is written in C, not C++.
Google for "compiler linker" and you'll find quite a few documents on how they work. That should help for documentation.
It's entirely possible to compile static libraries for the iPhone; what you can't do is compile dynamic libraries or frameworks - you could, but it's not encouraged.
Open your project
In the source/target browser, select the "Targets" node (with the little red and white target icon).
Right-click on the node, and in the popup menu select "Add", followed by "New Target".
A dialog opens. On the left hand side, there's an iPhone OS and a Mac OS X section. The iPhone OS section should already be selected; if not do so.
You should have three choices of targets, one of it is a static library. Select it, click OK.
Give the library a name in the next page. Click finish.
Your "Targets" node has includes a child for your static library now. You can add sources either via the file menu, or by dragging it onto the "Compile Sources" child node.
Hope that helps.
First, you do not need to rename any files to compile C++ code for the iPhone. Secondly, you'll want to create a separate project for the library. It looks like the iPhone target types don't include "static library", so you might need to create a Mac OS X project and modify it to output an ARM .a file. Not trivial, but probably doable.
Alternatively, if you're not going to be using this code in a lot of otherwise unrelated projects, you could include the source files directly into your App project. Collect them all into their own group, and you'll hardly know they are there.