View Single Post
Old 08-26-2014, 08:58 AM   #3
Veteran Programmer
SpaceManiac's Avatar
Join Date: Oct 2007
Posts: 3,076
Default Re: Problem: Functions In C

Originally Posted by Hammered View Post
Is there a reason why this is in total mayhem?
Confusion about where it was supposed to go, most likely. I imagine Making Dumb Games is good though.

Actual question answer: you're experiencing the fun of trying to compile multiple C source files into one program for the first time! (It's not that bad really).

I imagine you're trying a sequence of commands something like this, perhaps with more options:
gcc main.c
gcc fmin.c
What this tells the compiler to do is to try and make a complete program using only "main.c" and another one using only "fmin.c". Unfortunately, each file contains only part of the complete program - one is missing the definition (the code body) of "fminimum", and the other is missing the "main" function.

To compile both .c files at once into a single program, you want a command sort of like...
gcc main.c fmin.c
This tells the compiler to compile both source files as a single program, which is what you want. Now the finished program contains both a "main" function and the definition of the "fminimum" function.

There are more advanced techniques for compiling projects with many many source files rather than just a few but this should get you started.
SpaceManiac is offline   Reply With Quote