| | |
Make problem with implicit rule
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
hi,
i have the following structure in the "simple application":
application_folder
|
|--makefile
|
+-headers
| |
| +----func.h
|
|
+src
| |
| +------ func.c
| +------ main.c
|
|
and here are the contents of the files:
*func.h
*func.c
*main.c
and here is the makefile, where i try to use builtin rules to
reduce the size of it
the problem is that when i run gnu-make i only get:
so basically the built in rule for simple is never run.
To verify that there is a default rule for such cases,
i type gmake --print-data-base > gmake.database.txt
and when i read gmake.database.txt i find
so this should work but it doesn't.....
any ideas will be appreciated
-nicolas
i have the following structure in the "simple application":
application_folder
|
|--makefile
|
+-headers
| |
| +----func.h
|
|
+src
| |
| +------ func.c
| +------ main.c
|
|
and here are the contents of the files:
*func.h
c Syntax (Toggle Plain Text)
float hey(float a, float b);
*func.c
c Syntax (Toggle Plain Text)
#include "func.h" float hey(float a, float b) { return a+b; }
*main.c
c Syntax (Toggle Plain Text)
#include "func.h" #include <stdio.h> int main() { printf("%f\n", hey(4.4,4.4) ); return 0; }
and here is the makefile, where i try to use builtin rules to
reduce the size of it
C++ Syntax (Toggle Plain Text)
vpath %.c src vpath %.h headers CPPFLAGS = -I headers simple: main.o func.o main.o: func.h func.o: func.h
the problem is that when i run gnu-make i only get:
C++ Syntax (Toggle Plain Text)
cc -I headers -c -o main.o src/main.c cc -I headers -c -o func.o src/func.c
To verify that there is a default rule for such cases,
i type gmake --print-data-base > gmake.database.txt
and when i read gmake.database.txt i find
C++ Syntax (Toggle Plain Text)
# Implicit Rules %.out: %.a: %.ln: %.o: %: %.o # commands to execute (built-in): $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
so this should work but it doesn't.....

any ideas will be appreciated
-nicolas
Two roads diverged in a wood, and I— I took the one less traveled by, and that has made all the difference.
by Robert Frost the "The Road Not Taken"
by Robert Frost the "The Road Not Taken"
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
•
•
•
•
n is made automatically from n.o by running the linker (usually called ld) via the C compiler. The precise command used is ...
This rule does the right thing for a simple program with only one source file. It will also do the right thing if there are multiple object files (presumably coming from various other source files), one of which has a name matching that of the executable file....
In more complicated cases, such as when there is no object file whose name derives from the executable file name, you must write an explicit command for linking.
![]() |
Similar Threads
- How to be Crash Free (C++)
Other Threads in the C++ Forum
- Previous Thread: Looking for a good 5 day C++ class in Bay Area???
- Next Thread: Error?????
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






