james-collinss-macbook-pro:chap1 jamescollins$ gcc power1.c -o power1.out
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
got the following error message when i tried to compile a program from a book.
here is my test program which i called power1.c:
this was how the program appeared in the book.
one thing i noticed was the line
shouldn't this line end in a semi-colon?
when i added a semi-colon and recompiled the program i got the following from terminal:
james-collinss-macbook-pro:chap1 jamescollins$ gcc power1.c -o power1.out
power1.c:3: error: syntax error before { token
another thing i will mention is there is no main
i read from the book
"Normally you are at liberty to give functions whatever names you like, but "main" is special-your program begins executing at the beginning of main. This means that every program must have a main somewhere."
when i added main to the program i got the following error messages
james-collinss-macbook-pro:chap1 jamescollins$ gcc power1.c -o power1.out
power1.c:3: error: syntax error before main
power1.c: In function main:
power1.c:7: error: n undeclared (first use in this function)
power1.c:7: error: (Each undeclared identifier is reported only once
power1.c:7: error: for each function it appears in.)
power1.c:8: error: base undeclared (first use in this function)
any help would be appreciated.
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
got the following error message when i tried to compile a program from a book.
here is my test program which i called power1.c:
Code:
/* power: raise base to n-th power; n >= 0; version 2 */
int power(int base, int n)
{
int p;
for (p = 1; n > 0; --n)
p = p * base;
return p;
}
this was how the program appeared in the book.
one thing i noticed was the line
Code:
int power(int base, int n)
shouldn't this line end in a semi-colon?
when i added a semi-colon and recompiled the program i got the following from terminal:
james-collinss-macbook-pro:chap1 jamescollins$ gcc power1.c -o power1.out
power1.c:3: error: syntax error before { token
another thing i will mention is there is no main
i read from the book
"Normally you are at liberty to give functions whatever names you like, but "main" is special-your program begins executing at the beginning of main. This means that every program must have a main somewhere."
when i added main to the program i got the following error messages
james-collinss-macbook-pro:chap1 jamescollins$ gcc power1.c -o power1.out
power1.c:3: error: syntax error before main
power1.c: In function main:
power1.c:7: error: n undeclared (first use in this function)
power1.c:7: error: (Each undeclared identifier is reported only once
power1.c:7: error: for each function it appears in.)
power1.c:8: error: base undeclared (first use in this function)
any help would be appreciated.