How to Debug Following Program in Xcode - xcode

I'm using Xcode 3.2.1 on OSX 10.6.8, and I want to study how Avogadro works by debugging its source code. There is a CMake guide here:
https://web.archive.org/web/20160816105549/http://avogadro.cc/wiki/Compiling_on_Linux_and_Mac_OS_X
that explains how to do it (and the sources are provided), but I am not very familiar with debugging. How do I organize the source files into a new Xcode project and step through a compiled version?
Here is the git clone command:
git clone --recursive git://github.com/cryos/avogadro-squared.git
I spot a folder called /Users/Eric/Desktop/avogadro-squared/avogadro/avogadro/src but I'm unsure as to how to proceed with setting flags etc., since the project is originally compiled in Cmake.

I'm not familiar with Avogadro but I just downloaded the source. There are not any xcode projects that I could find. So if you want to use Xcode to debug it you will need to create the necessary projects. How do you do that? Well, Avogadro seems to be built up with several other sub modules, openqube, openbabel, and eigen in particular. So you will need to create xcode projects for them also (if they don't have them already.)
This is not a small job, you'll need to read the makefiles and see what libraries they need etc...
But, and this is the good news, once it is done you will have learn a lot about how Avogadro is built which will help you learn how Avogadro works, which was your goal.
And when you are done, you can then offer up your changes to the community, after all, that is what open source is all about, right?

Avogadro uses CMake, and CMake is a build system generator (part of the reason we chose it). So you can use its generator mechanism to request an Xcode build system. There is a general answer on StackOverflow to generate an Xcode project using CMake. You are looking at the superbuild which gathers/builds all dependencies - you really want to go into the avogadro subfolder and open that in Xcode.

Related

How to compile this GitHub Project on Mac? No instructions

I'm really interested in an Arduino IDE project from GitHub, but since I'm a new programmer i don't have figured out how to compile those source files on my Mac. There is already ported to Mac as it shows on the version 0.6.0.0 changelog but i just does not know how to do it.
Can someone provide instructions for me?
GitHub link:https://github.com/aporto/mariamole
So as I'm sure you've noticed, that project is a vcxproj-- i.e visual studio. Compiling it on Mac would require some finagling. I don't have experience myself, but I found this in my queries for you
How to support both vcxproj to cmake on a project?
You're going to want to read up on a lot of resources to try to get a better understanding and maybe form a better google query. Alternatively the easiest route would just to get your hands on a windows machine to build this
Good luck!
You have two options:
1) There's already a cmake project included in the project file. It's used for compiling it at Linux
2) There's also a Qt .pro file, also included in the project files, that you can load at Qt Creator

Can I use OpenFrameworks on OS X without having to use XCode?

I can't stand XCode, but really love OpenFrameworks, and I know it works on Linux+Win32 so I don't see why it should be XCode dependent. If I need to have XCode installed that's fine, I just don't want to use it at all.
Xcode internally uses gcc/llvm. in fact from the command line you can cd into a directory that contains an openFrameworks project and just type xcodebuild. but this won't allow you to edit the project file and add new source code, etc.
the Linux makefiles could be adapted to work on OSX as well. they already contain a lot of the information necessary about finding the correct source files, library paths etc. however Linux allows us to install many more components as shared system libraries, while on OSX we link most of the libs statically, so a number of extra library paths would need to be added. probably the biggest gotcha is that everything has to be compiled 32 bit, which means passing -arch i386 everywhere, so you can't just install dependant libs using Homebrew or MacPorts. we are in the process of transitioning to 64 bit but there are still some QuickTime calls that require us to stick with 32 bit, mainly around accessing legacy video capture devices that a lot of us still use for computer vision.
like #cdelacroix points out, we only maintain Xcode project files on OSX. this is mainly due to the lack of a decent alternative. there is a version of Code::Blocks for OSX but it is not very well supported, has some issues with native gui rendering and tends to lag behind the other platforms. Xcode is also the easiest way to install a toolchain on OSX so for most users installing Xcode is necessary.
if you do get a makefile based build system working, and would be interested in maintaining it medium to long term, please consider contributing it to the GitHub repository, it would be gladly accepted.
As of March 2013, openFrameworks has official makefile support for compiling the library itself. However, at the time of this writing, the changes haven't yet been merged into the stable release. You'll need to clone the Git repository and switch to the development branch.
git clone https://github.com/openframeworks/openFrameworks
cd openFrameworks && git checkout develop
cd libs/openFrameworksCompiled/project
make
As far as I can tell, we still need to use the unofficial solutions for compiling apps against the library.
You need Xcode, or at least a set of compilers (more information is available here), but otherwise, no, you can edit/work with the code in whatever editor or environment you want.
Here's a link to a makefile which will compile an OpenFrameworks application on OsX:
https://gist.github.com/labe-me/1190981
Place the makefile in the apps' directory and run make. Tested on OsX 10.6, but haven't tried with addons yet.
As #mipadi said, there is no requirement to actually use Xcode, you can do pretty much everything you do in Xcode with make or cake or any of your build system of choice. All you have to do is find the right set of command line options to pass to the usual tools (compiler, linker, strip, etc.), and sometimes the easier way is to... look in the Xcode build window how it is doing stuff (expand the lines with the small button on the right of each line).
For example you can link with your framework of choice with ld -framework Framework -FPathToFramework foo.o or your dynamic library with ld -lLib -LPathToDylib foo.o. You might have to learn about #rpath, #loader_path and install_name_tool to ship a self-contained packaged application.
As for OpenFrameworks, the "requirement" for Xcode is that the authors decided to maintain only Xcode project files. I just looked at how they do it, they ship source code and Xcode project files that build static libraries, so it will be even more simple for you (although you will need to link the library dependencies by hand). You will have to choose between compiling everything from source in your build system (if you want more customization power without touching Xcode), or just produce the 2 static libraries (openFrameworks.a and openFrameworksDebug.a) with Xcode once, then use them in your build system (recommended until you really need continuous customization).

Using Xcode for generic C/C++ development

I'd like to use all the power of Xcode for generic C/C++ projects but I can't figure out what are the basic steps to configure a new Xcode project and attach it to an existing source tree of a legacy, plain, C/C++ project.
Creating a new empty project, attaching it to a source tree and configuring a build target (using GNU Make) was a really silly task.
I can't figure out how to enable source code indexing in order to enable source refactoring tools, searching and fast-jumping and all the amenities that makes the Xcode programmer's life great.
Moreover I'd like to use the internal debugging facilities…
Does anyone point me to a tutorial, a hint or whatever could be useful?
Thanx
I've found a (dirty) path to enable refactoring tools:
I've added a new standard «console target» to the project and added all the source files under the Build Phases > Compiled Sources.
Refactoring tools now works. Having two targets doesn't seem to be a relevant issue (elegance apart)
Personally, I wouldn't attempt to use legacy Makefiles, even though I think there's some support for that.
Typically what I do with a traditional C/C++ project is to store my XCode project folder at the root of the project. So it might look like:
--myApp
--src
--inc
--myApp Xcode
I then drag the src folder and inc folder into the project navigator. This gives me an Xcode project to compile with on the Mac, and then I have the traditional Makefile for compiling on Linux (actually, I prefer CMake for other platforms, but either way works).

Generating Xcode projects by hand

I know how to build an existing Xcode project using xcodebuild, but I also need to generate Xcode projects from maybe a Python/Shell script. Is there any document somewhere that describes the process?
From personal experience generating xcode projects by hand is a pain; I've never seen a clear format defined anywhere, besides Apple keeps changing/adding stuff to it with each new version of Xcode.
I think the easiest way would be to use cmake/qmake or scons to generate your xcode project for you. For example, using cmake for this is pretty simple: you can have your script generate cmake makefiles, then run "cmake -G xcode" on those and it will create an xcode project for you. Also, since you mentioned python you could probably look into using scons for this purpose.
One possible way is to generate a project with Xcode and recreate the file hierarchy with your script.

Setting up a large Xcode project

I have a large exiting C++ project involving:
4 applications
50+ libraries
20+ third party libraries
It all builds fine on Windows using VS8, Linux using QMake (project uses Qt a lot). I also build it on OS X using QMake but I was wanting to setup an Xcode project to handle it in an IDE. I'm struggling to setup proper configuration to easily define dependencies, both to internal libraries and to the third party. I can do property sheets and .pri files in my (disturbed) sleep, but would appreciate some advice on building such large projects in Xcode.
I've been experiencing with Xcode configuration files and #including one from another but it does not seem to work as I would expect, especially when defining standard locations for header files etc.
Is there some good book describing the process of setting up Xcode (remember it's C++, I'm not wanting to learn ObjC at this time)?
Or maybe a good open source project I could learn from?
Thanks!
Step in to Xcode may be the book you're looking for. It's got a whole section devoted to using AppleScript to automate configuration includes. I've been going through the book myself on O'Reilly Safari as I've found myself in a situation similar to yourself!

Resources