Reputation: 41
This is part of a homework assignment. What we have to do is write a makefile to compile previous homework solutions. The solutions were provided by the professor, and they're what will be used to test our makefiles. One of the files has an #include "quicksort.c"
.
I know the usage of something like that is discouraged, but that doesn't really help me :)
What would be the best approach to getting the two files to compile (the file quicksortTest.c
, which includes quicksort.c
, and quicksort.c
itself)?
What I currently have as part of my makefile is the following:
quicksort: quicksort.c quicksortTest.c
$(CC) quicksortTest.c quicksort.c -o quicksortTest
Where quicksortTest.c
has the #include "quicksort.c"
.
When I try it, I get several gcc compiler errors... ideas?
Upvotes: 0
Views: 708
Reputation: 182794
Do it like this
quicksort: quicksort.c quicksortTest.c
$(CC) quicksortTest.c -o quicksortTest
Consider giving your teacher a C book.
Upvotes: 1
Reputation: 6919
Don't pass quicksort.c
to gcc
. Since you are including the file you should not compile it seperately:
quicksort: quicksort.c quicksortTest.c
$(CC) quicksortTest.c -o quicksortTest
Upvotes: 3