Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a C++ project in CodeBlocks/Eclipse that uses yacc and lex

I have the following makefile, which is working fine, to build my application. How can I configure an IDE (say, codeblocks, eclipse) to compile this. The C/C++ files associated with yacc are giving some errors when I try from eclipse/codeblocks. Is there any way to make eclipse/codeblocks to use an object file for some components directly while building/linking without specifying (including in project) the correponding .cc file? If so, I can use y.tab.o and lex.yy.o directly as those are not changing in my project.

CC = g++ -O2 -Wno-deprecated 

tag = -i

ifdef linux
tag = -n
endif

main.out: Sentence.o XOperation.o XOperationEngine.o Schema.o Doc.o TaskMan.o y.tab.o lex.yy.o test.o
    $(CC) -o main.out Sentence.o XOperation.o XOperationEngine.o Schema.o Doc.o TaskMan.o y.tab.o lex.yy.o test.o -lfl

main.o: main.cc
    $(CC) -g -c main.cc

XOperation.o: XOperation.cc
    $(CC) -g -c XOperation.cc

XOperationEngine.o: XOperationEngine.cc
    $(CC) -g -c XOperationEngine.cc

TaskMan.o: TaskMan.cc
    $(CC) -g -c TaskMan.cc

Doc.o: Doc.cc
    $(CC) -g -c Doc.cc

Sentence.o: Sentence.cc
    $(CC) -g -c Sentence.cc

Schema.o: Schema.cc
    $(CC) -g -c Schema.cc

y.tab.o: Parser.y
    yacc -d Parser.y
    sed $(tag) y.tab.c -e "s/  __attribute__ ((__unused__))$$/# ifndef __cplusplus\n  __attribute__ ((__unused__));\n# endif/" 
    g++ -c y.tab.c

lex.yy.o: Lexer.l
    lex  Lexer.l
    gcc  -c lex.yy.c

clean: 
    rm -f *.o
    rm -f *.out
    rm -f y.tab.c
    rm -f lex.yy.c
    rm -f y.tab.h
like image 573
Nemo Avatar asked Oct 13 '22 17:10

Nemo


1 Answers

If you already have Makefile, you can use 'Makefile project' in Eclipse. In this case Eclipse will use 'make' instead of internal builder to build the project.

like image 169
coldsteel Avatar answered Oct 18 '22 01:10

coldsteel