Tuesday, 17 September 2013

Including directories with gcc is not linking correctly

Including directories with gcc is not linking correctly

So I have a subdirectory with several files and need to link with it.
Inside the .c files I have an include that looks somewhat like:
#include "subdirectory/header.h"
this header file includes functions such as lex() that I am using and my
output on compiling is:
cc -IlexicalAnalyzer -Wall -c -o parser.o parser.c
cc -IlexicalAnalyzer -Wall -c -o recognizer.o recognizer.c
g++ -IlexicalAnalyzer -Wall parser.o recognizer.o -o recognizer
parser.o: In function `advance':
parser.c:(.text+0x36): undefined reference to `lex'
recognizer.o: In function `recognizer':
recognizer.c:(.text+0xd): undefined reference to `newLexer'
collect2: error: ld returned 1 exit status
make: * [recognizer] Error 1
What am I doing wrong?

No comments:

Post a Comment