• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to use Xcode with my project
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use Xcode with my project


  • Subject: Re: How to use Xcode with my project
  • From: Xochitl Lunde <email@hidden>
  • Date: Tue, 9 Feb 2010 09:55:06 -0600



<xcode-users-bounces+xochitl_lunde=email@hidden> wrote on 02/08/2010 04:48:02 PM:

> I am a newbie with Xcode trying to migrate from C to C++. I am not a
> good programmer.
> So far I have used Xcode only as an editor out of my ignorance at
> setting up IDEs.
> Since my program is getting bigger and bigger I do need a debugger
> and a development environment.
> I am writing a main program that calls functions beloning to a
> library called drl.
> My program is compiled by typing the following in a terminal shell:
> # g++ -Idrl -DYA_BLAS -DYA_LAPACK -DYA_BLASMULT -lblas -llapack -
> framework vecLib -o get_AllVar_matrix
>    get_AllVar_matrix.cc
> The executable is run with 3 input parameters from command line.
>
> Actually the name "library" is confusing as it leads professional
> developers to think of the typical library format (.so, .ar). I do
> not know the reason why Dr.L authors call it "library". Actually it
> is a collection of C++ source files (.cpp), include files (.h),
> organized in C++ classes and templates and members. Dr.L
> documentation is available on-line at
> http://www.cs.sandia.gov/~wmbrown/drl/index.htm.
> After downloading and uncompressing the tar-archive, all drl
> functions and includes etc ... can be called from any other source
> program as they are. That is, without pre-compilation.
> Guidelines to call drl functions from a program are provided in the
> on-line documentation.
> For instance, the first thing to do is to add the following to the
> program source code which uses it:
> #include "dimred/ya_dimred.h"
> using namespace yala;
>
> Basically the whole program is made up of my main
> "get_AllVar_matrix.cc" plus the drl ".cpp" functions I call and
> their respective include files. There are no .so or .ar files.
> Everything is to be compiled and linked at the same time.
> It's like a big program made up of a number of source files and
> includes files.
>
> Having said that, my question is: how can I create an Xcode project
> that contains my main program and also all drl
> source (.cpp, .h) code, and generate one only executable that can be
> run from command line and accepts some input parameters ?
>
> Thank you so much,
> Maura
>

I really recommend you consider buying a book on Xcode, they are not too expensive.  I have Xcode 3 Unleashed by Fritz Anderson, and it's been really helpful.

You can make a new project from the menu bar when you launch Xcode.  Click File->New Project. You should pick 'Command Line Tool' as the project type. Here's the tip, put your Xcode project at the top level of your project and name it the same as the folder.  If your source is in folder 'foo/src', you want to put your project in folder 'foo'.  This means you need to name your project 'foo' and put it in 'foo's parent folder.  If you put it in the parent of 'foo' but give the project the name of 'foo', then Xcode will automatically put the project in 'foo' with a name of 'foo.xcodeproj'.  In my experience from the last year dealing with porting over C++ programs, I would say that this is what you want to do.  You can name an Xcode project however you want, and put it wherever you want, but these naming rules have made things a LOT easier for me.  I got much better at using Xcode after I was able to stop fighting with it over file paths.

When your project opens, you'll have the Groups And Files pane on the left, and you should Add Existing Files.. (right click menu) to your project Source.  You can pick 'foo/src' and recursively add folders and files from inside 'foo/src'.  You can add multiple sets of sources, so if you need to add your library as a second step, you can.

Xcode should have created a Target for you, which is your command line tool target.  Highlight all the source files you want to compile in your groups and files Source list, and drag them down to the "Compile Sources" for the target (you might need to open the disclosure triangle).

Double click on the target to get the window that lets you setup all the build rules.  The build tab lets you put in your preprocessor macros and library header search paths.  Some of this you might want to do in the project settings, because settings for individual targets will override the project settings.  Project settings are in the menu bar at Project->Edit Project Settings.  You can't set up some of the choices, like preprocessor macros, until you have added the compile sources to the target, so make sure you did that first.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How to use Xcode with my project (From: <email@hidden>)

  • Prev by Date: Re: make connections without InterfaceBuilder
  • Next by Date: Re: make connections without InterfaceBuilder
  • Previous by thread: Re: How to use Xcode with my project
  • Next by thread: Problems with Organizer
  • Index(es):
    • Date
    • Thread