Getting To Know Apple


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) Getting To Know Apple
# 1  
Old 11-14-2010
Getting To Know Apple

I just started learning my first language 6 months ago; I chose C, because it is the ancestor of many more modern languages. I am now about to move on to Objective-C. I was also wondering, what other languages are supported in XCode, and how do you access them?
A more relevant question for me is also, how do you program in the terminal app?
I will be going to the university for computer science in the fall, any recommended reading for apple, unix, linux. I would like to learn unix for interacting with my current system(snow leopard) and linux because it is stable and is good for cross-platform interaction. Also, any tips on languages to learn? I am intermediate in C. Just starting objective-c. But, I also hear that: python, c++, java are all good to begin with. Thanks.Smilie

---------- Post updated at 10:08 PM ---------- Previous update was at 12:27 AM ----------

My statement was kind of broad. How do you program using terminal, I am using xcode directly, but would like to use the terminal.

Last edited by DukeNuke2; 11-14-2010 at 05:05 AM..
# 2  
Old 11-17-2010
Program in C?

The simple way, for simple programs:
Code:
$ gcc filename.c -o filename

The still pretty simple way for programs with more than one source file:

Code:
$ gcc file1.c file2.c file3.c -o filename

Or compiling into object files for linking later:

Code:
$ gcc -c file1.c ; gcc file2.c ; gcc file3.c
$ gcc file[123].o -o filename

Or letting a makefile do the above for you, with places to insert the options you want:

Code:
# This file should be named makefile or Makefile, and be in the same
# directory as file1.c, file2.c, file3.c

# This variable is used by the predefined rule for converting .c into .o
# files.  You don't need to tell it to convert .c into .o, it assumes it when
# you tell it it needs .o files.  It feeds it into cc's commandline options.
# -Wall simply makes compiler warnings more verbose.
CFLAGS=-Wall

# This traditional variable tells the linker command below to link in the optional math library.
LDFLAGS=-lm

# $(CC):  Your default compiler.  You can change it if you want.
# $(LDFLAGS):  Linker options.  You can set these too.
# $^        All input files.  in this case file1.o file2.o file3.o
# $@        The output file.  In this case filename
# The rule itself says 'make filename from file1.o, file2.o, and file3.o'.
# The line below tells it how.
# Note the eight spaces in front of $(CC) should really be and MUST be a tab
filename:file1.o file2.o file3.o
        $(CC) $(LDFLAGS) $^ -o $@

Code:
$ make
cc -Wall   -c -o file1.o file1.c
cc -Wall   -c -o file2.o file2.c
cc -Wall   -c -o file3.o file3.c
cc -lm file1.o file2.o file3.o -o filename
$

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question