[nmglug] Solar Position Algorithm (SPA)

Anthony J. Bentley anthony at cathet.us
Tue Nov 11 20:23:40 PST 2014


Hi Anthony,

a writes:
> I did chmod +x on above probably not necessary but same result as w/o chmod

chmod +x isn't necessary here. Doesn't make any difference in the result.

> a at a-laptop:~/Documents/spa$ gcc -o spa_tester spa_tester.c
> /tmp/ccQbHXvm.o: In function `main':
> spa_tester.c:(.text+0xc7): undefined reference to `spa_calculate'
> collect2: error: ld returned 1 exit status

spa_tester.c calls the spa_calculate() function, but the body of the
spa_calculate() function is in spa.c. You need to compile both files
together, like so:

$ cc -o spa_tester spa_tester.c spa.c -lm

This is basically shorthand for the following:

$ cc -c spa_tester.c
$ cc -c spa.c
$ ld -o spa_tester -lm spa.o spa_tester.o

This article might be a helpful explanation of what these operations mean:
http://nethack4.org/blog/building-c.html

-- 
Anthony J. Bentley


More information about the nmglug mailing list