tags:

views:

1008

answers:

2

Hi,

I have all my source files in the Source folder, The makefile is in the Makefile folder and I want all object files to be placed in Objects folder. It is a C project iam working on. All these three folders are in a folder named Project.

Project folder contains: Source Makefile Objects

iam trying to figure out a way to get the makefile to compile source from Source folder, i have tried using:

...
SOURCE_DIR=..\Source
OUTPUT_DIR=..\Objects
.c.obj:
    $(CC) $(SOURCE_DIR)\$*.c /Fo$(OUTPUT_DIR)\$*.obj
...

but this is not working, i end up with an error message while says dont know how to make myfile.obj

+1  A: 

Try this:

SOURCE_DIR=..\Source
OUTPUT_DIR=..\Objects
{$(SOURCE_DIR)}.c{$(OUTPUT_DIR)}.obj:
    $(CC) $* /Fo$<

As explained here: http://msdn.microsoft.com/en-us/library/hk9ztb8x.aspx

Ron
A: 

If it is literally saying don't know how to make myfile.obj, and not don't know how to make ..\Objects\myfile.obj then your problem is elsewhere - something in the makefile is asking for an object file in the current directory.

What is the rule that needs myfile.obj to build? I would guess that in that rule you are failing to specify $(OUTPUT_DIR)\myfile.obj as the dependency.

Hugo van der Sanden