Some thoughts on bignum...
- We are on the edge of developing a library here...
- Could we use the bignums in our function package?
- What would we need to do to make this happen?
- The c compiler supports a flag (-c)
- Compile but do not link.
- Produce a .o file.
- We can't have a main in our routine then however.
- g++ -c bignum.C
- This will make bignum.o
- We can then link this with another program (main.C)
- g++ -o main main.c bignum.o
- We probably should create a bignum.h file as well.
-
- A Makefile helps with compiling then.
- .h file
- Called a specification file
- Also called a header file
- Contains:
- Constants.
- Structure declarations.
- Procedure prototypes for library.
- bignum.h
- Implementation file
- Contains the actual procedures
- Should include the header file
- Should not include a main.
- bignum.C
- Routines that use this package
- Should include the header file.
- Declare variables of the type
- Can call the routines.
- main.C
- A Makefile
- Two new lines here:
-
main: bignum.o
- This says that main depends on bignum.o
- So compile bignum.o before you try to build main
-
clean:
rm main *.o
- This tells us how to make clean
- Remove all of the junk
- One trickey thing,
- TAB before rm main *.o
- Makefile
- make -n
- Will show us what we would do if we type make
- make -n clean