15-05-2010, 23:10
|
|
|
|
חבר מתאריך: 04.11.04
הודעות: 6,986
|
|
עזרה עם קובץ Makefile
אני צריך ליצור קובץ Makefile לתכנה שיצרתי לצורך קומפילציה ב-Unix, אבל אני לא ממש מבין בזה ודי מסתבך...
מלבד הקבצים שאני יצרתי אני גם לצרך לקשר קובץ אובייקט mtm_ex2.o וקובץ ספרייה libcontainers.a.
את רשימת התלוית השגתי באמצעות הפקודה gcc -MM *.c
זה קובץ ה-Make
קוד:
EXEC = mtm_cellular
MAIN_OBJ = main.o
MAIN_SRC = main.c
OTHER_SRC = account.o call.o cellular_company.o familyLine.o implementation_utilities.o \
message.o normalLine.o phoneLines.o relative.o talkerLine.o
OTHER_OBJS = libcontainers.a mtm_ex2.o
CC = -std=c99 -Wall -Werror -pedantic-errors mtm_ex2.o -L"." -lcontainers
$(EXEC) : main.o $(OTHER_SRC) $(OTHER_OBJS)
gcc $(OTHER_SRC) -o -DNDEBUG $(CC) *.c
$(MAIN_OBJ): $(MAIN_SRC) cellular_company.h account.h list.h phoneLines.h set.h \
message.h call.h relative.h general_utilities.h \
implementation_utilities.h $(OTHER_OBJS)
gcc -c main.c -DNDEBUG $(CC)
account.o: account.c list.h set.h mtm_ex2.h general_utilities.h \
implementation_utilities.h account.h phoneLines.h message.h call.h \
relative.h $(OTHER_OBJS)
gcc -c account.c -DNDEBUG $(CC)
call.o: call.c list.h set.h call.h general_utilities.h \
implementation_utilities.h cellular_company.h account.h phoneLines.h \
message.h relative.h mtm_ex2.h $(OTHER_OBJS)
gcc -c call.c -DNDEBUG $(CC)
cellular_company.o: cellular_company.c list.h set.h cellular_company.h \
account.h phoneLines.h message.h call.h relative.h general_utilities.h \
implementation_utilities.h mtm_ex2.h normalLine.h familyLine.h \
talkerLine.h $(OTHER_OBJS)
gcc -c cellular_company.c -DNDEBUG $(CC)
familyLine.o: familyLine.c mtm_ex2.h general_utilities.h \
implementation_utilities.h list.h set.h familyLine.h phoneLines.h \
message.h call.h relative.h $(OTHER_OBJS)
gcc -c familyLine.c -DNDEBUG $(CC)
general_utilities.o: general_utilities.c general_utilities.h
gcc -c general_utilities.c -DNDEBUG $(CC)
implementation_utilities.o: implementation_utilities.c \
implementation_utilities.h list.h set.h
gcc -c implementation_utilities.c -DNDEBUG $(CC)
message.o: message.c mtm_ex2.h general_utilities.h \
implementation_utilities.h list.h set.h message.h $(OTHER_OBJS)
gcc -c message.c -DNDEBUG $(CC)
normalLine.o: normalLine.c mtm_ex2.h general_utilities.h \
implementation_utilities.h list.h set.h normalLine.h phoneLines.h \
message.h call.h relative.h $(OTHER_OBJS)
gcc -c normalLine.c -DNDEBUG $(CC)
phoneLines.o: phoneLines.c set.h list.h general_utilities.h \
implementation_utilities.h mtm_ex2.h phoneLines.h message.h call.h \
relative.h normalLine.h talkerLine.h familyLine.h $(OTHER_OBJS)
gcc -c phoneLines.c -DNDEBUG $(CC)
relative.o: relative.c list.h set.h general_utilities.h \
implementation_utilities.h relative.h $(OTHER_OBJS)
gcc -c relative.c -DNDEBUG $(CC)
talkerLine.o: talkerLine.c mtm_ex2.h list.h set.h talkerLine.h \
phoneLines.h message.h call.h relative.h general_utilities.h \
implementation_utilities.h $(OTHER_OBJS)
gcc -c talkerLine.c -DNDEBUG $(CC)
clean:
rm -f $(OTHER_SRC) $(EXEC) $(MAIN_OBJ)
וזה רשימת השגיאות שאני מקבל שאני מנסה להריץ אותו:
קוד:
stomer83@stud > make
gcc account.c -DNDEBUG -std=c99 -Wall -Werror -pedantic-errors mtm_ex2.o -L"." -lcontainers
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/crt1.o(.text+0x21): In function `_start':
: undefined reference to `main'
/tmp/cc6UCXQR.o(.text+0x28): In function `addLine':
: undefined reference to `compareLine'
/tmp/cc6UCXQR.o(.text+0x2d): In function `addLine':
: undefined reference to `freeLine'
/tmp/cc6UCXQR.o(.text+0x32): In function `addLine':
: undefined reference to `copyLine'
/tmp/cc6UCXQR.o(.text+0x10f): In function `createAccount':
: undefined reference to `allocateString'
/tmp/cc6UCXQR.o(.text+0x11f): In function `createAccount':
: undefined reference to `allocateString'
/tmp/cc6UCXQR.o(.text+0x1d2): In function `copyAccount':
: undefined reference to `allocateString'
/tmp/cc6UCXQR.o(.text+0x1e6): In function `copyAccount':
: undefined reference to `allocateString'
/tmp/cc6UCXQR.o(.text+0x492): In function `getAccountLastBill':
: undefined reference to `lineLastBill'
/tmp/cc6UCXQR.o(.text+0x506): In function `printLines':
: undefined reference to `compareLine'
/tmp/cc6UCXQR.o(.text+0x54b): In function `printLines':
: undefined reference to `printLine'
/tmp/cc6UCXQR.o(.text+0x5be): In function `calculateLines':
: undefined reference to `calculateLine'
/tmp/cc6UCXQR.o(.text+0x638): In function `accountAddRelativeToLine':
: undefined reference to `addLineRelative'
/tmp/cc6UCXQR.o(.text+0x6b2): In function `accountPrintCallsForLine':
: undefined reference to `printCallsToPhoneLine'
/tmp/cc6UCXQR.o(.text+0x701): In function `accountPrintMessages':
: undefined reference to `printMessagesForLine'
/tmp/cc6UCXQR.o(.text+0x750): In function `accountPrintCallsToLineRelative':
: undefined reference to `printCallsToLineRelative'
/tmp/cc6UCXQR.o(.text+0x79f): In function `addMessageToAccount':
: undefined reference to `addMessageToLine'
/tmp/cc6UCXQR.o(.text+0x7ee): In function `addCallToAccount':
: undefined reference to `addCallToLine'
collect2: ld returned 1 exit status
make: *** [account.o] Error 1
אשמח לכל עזרה
נערך לאחרונה ע"י RP. בתאריך 15-05-2010 בשעה 23:27.
|