2014-12-11 3 views
-1

cpp2html.c를 컴파일하여 makefile을 작성하여 cpp2html.o를 생성하려고합니다 (이 작업을 완료했습니다). 다음으로 flex cppscanner.l을 실행하여 언어 cppscanner.l에서 lex.yy.c 파일을 생성해야합니다. (나는 이것을했다). 그렇다면 lex.yy.c를 컴파일하여 lex.yy.o를 생성해야합니다. 그리고 .o 파일을 마지막으로 연결하십시오. (모두 완료)flex를 사용하여 Makefile 오류가 발생했습니다.

cpp2html.o: cpp2html.c 
[TAB] gcc -g -DDEBUG -c cpp2html.c //produces cpp2html.o 

lex.yy.c: cppscanner.l 
[TAB] flex cppscanner.l -o lex.yy.c //produces cppscanner language on lex.yy.c 

lex.yy.o: lex.yy.c 
[TAB] gcc -g -c lex.yy.c    //produces lex.yy.o 

cpp2html: cpp2html.o lex.yy.o 
[TAB] gcc -g -DDEBUG cpp2html.o lex.yy.o -o cpp2html //links the .o files 

내가 호출 할 때 귀하의 메이크가 'cpp2html'를 구축하지 않습니다 "입니다 실행할 때 생성 된 오류 : GCC -g -DDEBUG -c cpp2html.c

내가 무슨 일을하고있는 중이 야 ? 미리 감사드립니다

+0

실제로 모든 탭에서 탭이 누락되었거나 복사하여 붙여 넣기에 실패 했습니까? – juanchopanza

+0

복사하여 붙여 넣기가 실패합니다. 내 잘못 – amdc

답변

0

오류 메시지는 규칙이를 철자가 어딘가. 두 번 확인합니다 (.o 누락 목표) 규칙

cpp2html: cpp2html.c 
    gcc -g -DDEBUG -c cpp2html.c 

이 있음을 시사한다 그것은 당신의 게시물에 있고, 다른 makefile은 없다는 것입니다.

+0

내 문제는 내 파일이 파일의 맨 아래에 있음을 확신합니다. 그래서 나는 cpp2html : cpp2html.o lex.yy.o를 파일의 맨 위로 옮기고 디렉토리에서 모든 .o 파일을 삭제했다. 감사! – amdc

0
gcc, when given no output file name, 
produces a file with the default name 
(I'm thinking a.out, but don't quote me) 
suggest: 

BTW: the comment in a make file is started with '*' not '//' 

BTW: perhaps there are no .h files, but if there are, they need to be 
    listed as dependencies and 
    if the header files are in the same directory then -I. needs to be appended 
    to the compile statements, 
    otherwise replace the '.' with the path to the header files 

BTW: perhaps there are no libraries being used, 
    but if there are then 1) the path to the library needs to be appended to the 
    link operation via -Lpathtolibrary and -llibraryname 

BTW: by using the built-in rules and the make file shortcut parameters 
    (like $&, $< $> [email protected]) a single rule can replace many similar rules) 
    and creating some macros like: SRC := (wildcard:*.c) or YACC := (wildcard:*.l) 
    and pattern replacement macros like: 
     OBJ := $(SRC:.c=.o) $(YACC:.l=.o) 
    a lot of code in a makefile does not need to be repetitive 

* the 'all' target is first so user can just say 'make' with no parameters 
* .PHONY lists those targets that will not produce a file with the same name 
*  as the target 
.PHONY: all 
all: cpp2html 

cpp2html.o: cpp2html.c 
[TAB] gcc -g -DDEBUG -c cpp2html.c -o cpp2html.o 

lex.yy.c: cppscanner.l 
[TAB] flex cppscanner.l -o lex.yy.c 

lex.yy.o: lex.yy.c 
[TAB] gcc -g -c lex.yy.c -o lex.yy.o   

* this does the link to produce the executable 
cpp2html: cpp2html.o lex.yy.o 
[TAB] gcc -g -DDEBUG cpp2html.o lex.yy.o -o cpp2html