first time compiling with external .c and .h file, doesn't work

This is a discussion on first time compiling with external .c and .h file, doesn't work within the C Programming forums, part of the General Programming Boards category; Im trying to compile this program with gcc, i used this makefile:
start: HW4.c header.h functions.c
but the compiler isn't ...

I'm not sure why you aren't just putting the standard includes in the files they are individually needed in, instead of putting them in this header. Also, I'm not sure why you are using "" instead of <> for those two includes.

I added the guards and took out the extra header includes, but it still isn't finding the functions in function.c -- something is wrong with my makefile or something. I got it to compile fine in Visual C++, but now when I try in GCC I get nothing but errors.

I assume you're typing "make start". You appear to have the right prerequisites -- what is the command line you have on the line below the one you give? (Or are you trying to use the automatic figure-it-out-from-the-file-extensions rules?)

You do realize that you need to compile both C files, then link them into the executable... compiling only the main file will not work.

No, I really have no idea what I'm doing, and I don't know how to do that either. I have vi, and make, and gcc, and some kind of linux interface and I have no idea how I'm supposed to compile a program in it, nor can I find any coherent explanations. Visual C++ is so much easier, all I have to do is click "build" :<

No, I really have no idea what I'm doing, and I don't know how to do that either. I have vi, and make, and gcc, and some kind of linux interface and I have no idea how I'm supposed to compile a program in it, nor can I find any coherent explanations. Visual C++ is so much easier, all I have to do is click "build" :<

I assume you're typing "make start". You appear to have the right prerequisites -- what is the command line you have on the line below the one you give? (Or are you trying to use the automatic figure-it-out-from-the-file-extensions rules?)

If I type "make start", it says there is nothing to do with start. I don't have any other lines in my makefile, I think I'm trying to use the automatic rules which I was told would work if I did it right.

Okay, Please post, in full, and in separate sets of code tags, the following files:
HW4.c
functions.c
header.h
Makefile

I'm guessing you don't know how make files work. The only line you posted for your make file says the start target relies on those files, but does not specify any action to perform, like "gcc -Wall -Werror $?". You probably need to read up a bit on make files. I strongly suggest using the -Wall (enable all warnings) and -Werror (treat warnings like errors, i.e. stop compilation on warnings) flags to ensure you're writing good, clean code.

There's a huge number of other problems with your code that will become apparent when you try to compile (VC++ should have warned about much of this too, especially if you're compiling with /W3 or /W4). We can go over those once you post up your files.

The only line you posted for your make file says the start target relies on those files, but does not specify any action to perform, like "gcc -Wall -Werror $?".

I was told make would know what to do. I certainly don't know what to do. I just want it to compile them the most simple basic way it can.

Originally Posted by anduril462

There's a huge number of other problems with your code that will become apparent when you try to compile

Well, the original of this worked fine with VisualC++. I'm sure there are some differences that will have to be ironed out, which is why I was trying to do this in order to see what those differences are, but I can't even get it to compile. I did get it to compile as one big file, but I'm trying to figure out how to compile with more than one file.