Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Destination of object files

gib
New Contributor II
380 Views

(I'm working on Windows)

The makefile I've inherited, for gcc, compiles various components of the project in place in different subdirectories. I can't figure out how to make icl put the object file in the same place as the source file (except by explicitly specifying the diirectory).

That is,

icl -c foo\\bar.c -Fofoo\\

creates foo\\bar.obj

but I don't know how to write the general rule in the makefile, to replace the gcc version:

.c.o:
$(CC) $(CFLAGS) $< -o $@

0 Kudos
4 Replies
TimP
Honored Contributor III
380 Views

Do you mean you want a .o file rather than .obj? The only way I know of is to rename it in the Makefile rule.

A .c.obj rule should work fine, with appropriate settings for CC and CFLAGS, if you have added .obj to the .SUFFIXES rule.

If you are using a proprietary Windows-specific make, the answer will depend on the specific make you have chosen. I would suggest gnu make, if you are trying to modify a gnu makefile.

0 Kudos
gib
New Contributor II
380 Views

No, I don't mean I want .o object files. I just copied the lines from the original makefile verbatim. I have been using

.c.obj:
$(CC) $(CFLAGS) $<

which puts the object files in the working directory. I haven't added a .SUFFIXES rule (the original makefile doesn't have one). Will that make a difference? If so, what should it look like?

Thanks.

0 Kudos
Dale_S_Intel
Employee
380 Views

Are you using Cygwin or something similar that provides you with unix utilities like dirname? If so you could do something like

$(CC) $(CFLAGS) $< -Fo`dirname $<`\

but I think cygwin will give you forward slashes which might confuse things.

Dale

0 Kudos
TimP
Honored Contributor III
380 Views

gnu make defaults to treating .o but not .obj as a SUFFIX (even if built for Windows)

.SUFFIXES: .obj

0 Kudos
Reply