I'm trying to set up SDL with Xcode using the tutorial here.
http://www.sdltutorials.com/sdl-tutorial-basics
I have everything set up correctly according to this tutorial, and there are no errors after building. The only problem is that when I run the program, the SDL_Surface never appears. The console says nothing and no errors are thrown. I've been searching for solutions for says, but I am unable to find anything that relates to my issue. I put my code up here on Git if anyone would like to check it out and tell me what I'm doing wrong. Thanks so much!
https://github.com/syobonaction/rubicon.git
This is a silly but easy mistake to make!
In your project, you have included main.m (included in a default cocoa application project) and have not included SDLMain.m, so your SDL code is never executing, and instead you are just running a blank Cocoa application!
To fix this, click on SDLMain.m, open the utilities pane on the right, and click the checkbox to add SDLMain.m to your target. Next, go to Supporting Files in your left navigation pane, find main.m, and delete it from your project. You don't need main.m at all, because all it does is start a Cocoa application, which you don't want to do! (SDLMain.m will also start a cocoa application, but not before linking the cocoa application to the SDL system.)
Related
I am building a C++ OpenGL card game in Xcode 4.3.3, with the intention of running it on both 64-bit and 32-bit Macs, which is not my problem. My problem is that I have reached a point in the development of the program where I would like to test that it works on a different 32-bit Mac (mine is 64-bit) without having to install Xcode. This, obviously, requires me exporting it as an .app. I can find and run the exported Unix Executable File from my project, after some cd'ing, through Terminal, but that is undesirable for me and the intended audience of the program. I have trawled the google and Stack Overflow, looking for anything to help me, but all the things mentioning Archiving seem to have been unsuccessful with my particular project, and I think that's because it's a C++ command line tool project. So, can someone please help me export my project as a .app?
Thanks in advance.
The simplest way of doing this would be to create a Cocoa project, go to 'build phases' and remove all the objective-c frameworks from the 'link with libraries' build phase, remove any objective-c files added by the template (app delegate, etc.) and then replace main.c with your main.cpp file.
There's nothing really special about a Cocoa project except for the fact that it links against Cocoa and calls NSApplicationMain() from its main() function.
There are also a bunch of .plist entries used by Cocoa which you'll no longer need. But they won't affect the way OS X treats your application.
I'm searching for an XCode Settings solution but here's my current way to create an app:
You have to take your binary file (let say myapp) and put it in "MyApp.app/Contents/MacOS/myapp" then it can now be launched as a .app. That's a trick.
Just go to the targets folder in the file navigator on the left, and there will be an executable listed there. Left click on that executable and click "show in finder". (I'm describing from memory so I may have the exact details wrong.) The file path is ridiculously long (there is an arbitrary alphanumerical pathname involved, I have no idea why), so you probably won't be able to find it with the command line.
If you want you can change the extension of the file from nothing to ".app", it shouldn't affect the nature of the file at all. Also if you want a custom icon, you can "get info" on it in the finder, then click on the icon in the info window, and use Cmd-V to paste it in (obviously you have to have your icon copied to the clipboard). There is also a way to do this inside of Xcode, but I don't remember it.
I am currently writing a super basic plugin using the JUCE framework and C code generated from a the Heavy Pure Data Online Compiler. The source code builds fine, however no standalone application, AudioUnit or VST are created by Xcode. My guess is that the project is not setup properly to use the included code, however I am still learning my way around Xcode and can't seem to work out what the problem is to fix the below errors. Any suggestions on how I can fix this?
Edit: Finally started using git and uploaded the project to GitHub here.
The projucer file you included is missing the heavy source folder. Add them in projucer on the left side in the file explorer area (right click in the file area on source and choose add existing files...
Hint the save and open in ide icon on top of the window
and there you go ... no linker error.
tested with XCode 8.3.3
Two remarks:
Never add files anywhere else than in projucer
You canĀ“t use XCode 9 beta with JUCE
So im a bit confused by what to-do with this current pop-up im having from QT. Not entirely sure what it means.
So i'm trying to create a C++ Library, as a static linked library. Currently the library has no code in it whatsoever.
Immediately hitting the build button to make sure everything runs fine the following pop-up below is displayed.
Im not sure what this means exactly. Or indeed, why it is even being shown in the first place. building any of my other project files works fine without issue. But this does not.
.
As for what i have, i am using the Qt SDK, version 4.8.1.
Any help solving this issue would be greatly appreciated :).
A library [usually] needs to be invoked from an executable - The dialog box you are seeing is asking you to specify an executable that will bring your library into life and call functions within it.
You need to write a client executable (or use an existing executable) to use your library and specify the path in this dialog box.
The button you clicked was probably the Run button:
, not the build button: .
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
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.