Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

compiling a C program for the first time

I have been having some trouble compiling a program (it is written in C, and it is a compiler for z80 assembly, which is irrelevant). I have a feeling that there is something i need to configure that i haven't. what are the steps for compiling a program for the first time?

dont assume i understand something, as I understand very little. I have downloaded Xcode and all of its associated utilities.

I have limited ability in terminal (i know cd, mkdir, cp, open, exit, and that is about it).

intel imac 1.8Ghz, Mac OS X (10.4.8)

Posted on Jan 25, 2007 6:34 PM

Reply
14 replies

Jan 25, 2007 7:17 PM in response to Ken Nellis

i tryed "make tpasm" and got:

cc -O globals.o tpasm.o memory.o files.o symbols.o label.o segment.o pseudo.o parser.o context.o alias.o macro.o listing.o outfile.o processors.o support.o outfiles/intel_seg.o outfiles/mot_seg.o outfiles/sunplus_sym.o outfiles/text_sym.o processors/6502.o processors/6805.o processors/6809.o processors/68hc11.o processors/8051.o processors/avr.o processors/ctxp1.o processors/pic.o processors/sunplus.o processors/z80.o -lstdc++ -o tpasm
/usr/bin/ld: Undefined symbols:
_UnwindResume
collect2: ld returned 1 exit status
make: * [tpasm] Error 1

I have read about ./configure, but when i try that, i get "-bash: ./configure: No such file or directory"

Jan 25, 2007 7:28 PM in response to socal swimmer

Hi--

I have no idea if this creates a usable binary or not, but it finishes compiling and linking:

1. Open the Makefile and look for the following line:

<pre class="command">$(CC) -O $(OBJECTS) -lstdc++ -o tpasm</pre>Change the last line there to read like this:

<pre class="command">$(CXX) -O $(OBJECTS) -lstdc++ -o tpasm</pre>Then, just do make at the command line. No need for "tpasm".

You'll get a couple of errors, but nothing fatal. And the binary prints the usage information on my iMac, at least.

charlie

Oh, I shouldn't take credit for that fix, by the way, I got it here.

Message was edited by: Charles Minow

Jan 25, 2007 9:05 PM in response to socal swimmer

well hm. i typed in "make" and got this:

"g++ -O globals.o tpasm.o memory.o files.o symbols.o label.o segment.o pseudo.o parser.o context.o alias.o macro.o listing.o outfile.o processors.o support.o outfiles/intel_seg.o outfiles/mot_seg.o outfiles/sunplus_sym.o outfiles/text_sym.o processors/6502.o processors/6805.o processors/6809.o processors/68hc11.o processors/8051.o processors/avr.o processors/ctxp1.o processors/pic.o processors/sunplus.o processors/z80.o -lstdc++ -o tpasm"

and NO ERRORS! so i guess it worked. But where does the made file go? i cant find it ...

Jan 25, 2007 10:12 PM in response to Charles Minow

ok. i have to include the full path to tpasm, then space, then the source file. i finally got a source file to compile, but, now, i cant find it. But i think that that will be a more specific thing, something you probably couldn't help me with.
But thank you! your help has been very ... helpful.

it turns out tpasm just looked like a normal document, but when opened, looked wierd (weird symbols) but it does run in terminal.

Jan 26, 2007 3:00 PM in response to socal swimmer

You don't need to type the full path. Look again at what Charles told you. And if you enter the following command:

echo $PATH

you'll get a list of colon-separated directories where your shell looks to find programs to execute. If you move (mv) your binary into one of them, then you won't need to type any path info, regardless of what directory is your current working dir.

Jan 28, 2007 4:49 PM in response to socal swimmer

Hi socal swimmer,

> this is cool.

That's always good to hear; naturally we tend to agree. Allow me to suggest my favorite reference, the Advanced Bash-Scripting Guide. Don't let the title fool you; "Advanced" refers to the completeness of the reference. It actually assumes very little.

There are a number of more pedantic articles, tutorials and books. I used to have a long post of links to what I think are some of the better beginning UNIX reference material. However, as others posted great links and I stole them, my post became too long so I put it in a web page. Bill Scott did the same thing so here is Bill's and here is mine.
--
Gary
~~~~
University politics are vicious precisely because the
stakes are so small.
-- C. P. Snow

compiling a C program for the first time

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.