Skip to main content
GameDev.net gamedev.net
🔒 Locked

Makefile help

Started by Fibonacci One Oct 5, 2004 at 12:48 PM 2 replies 500+ views
Original Post
Fibonacci One
Fibonacci One
So, I'm working on a simple program in C and I figured I may as well go ahead and use this to learn how to use makefiles. Now, I can get single file programs to work just fine, but now I'm trying to make a program that draws from two files.

the directory structure looks like this:
Project
--Includes
  -BinaryTree.h
--SRC
  -BinaryTree.c
  -Project.c
-Makefile

As you have probably already assumed, Project.c includes BinaryTree.h with includes BinaryTree.c and the makefile I'm trying to use (I took out all of the bash stuff, but it's still the same thing):

all:	Project.o BinaryTree.o
		ld Project.o BinaryTree.o
Project.o:	BinaryTree.o
		gcc -g SRC/Project.c 
BinaryTree.o:	
		gcc -g SRC/BinaryTree.c 


When I run make, I get all sorts of "Multiple Definition of _something" errors. I'm guessing this means I'm linking them incorrectly because I know I never created any _somethings.
Fibonacci One
Fibonacci One
Thank you, whoever you are!

Works quite nicely now...
Zahlman
Zahlman
Also, it is probably a bad idea to be including the BinaryTree.c file from the .h. The .h is supposed to contain everything that Project.c needs to know about BinaryTrees (i.e., interface, not implementation), and the other stuff doesn't need to be included yet. It gets compiled in the BinaryTree.o, and reunited when you do the linking. :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.