0

I am getting below error,

Focus//build/libfocus.a(FocusParser.o): In function FocusParser::parse(std::string const&)': /builddir/project/src/Focus/FocusParser.cpp:22: undefined reference toyyFC_scan_bytes(char const*, int)'

The code is as follow. As seen in the code the function is already defined on line 12. Please help.

  1 #include <stdio.h>
  2 #include <errno.h>
  3 #include <string.h>
  4
  5 #include "Exception.h"
  6 #include "Builder.h"
  7
  8 #include "FocusParser.h"
  9 #include "FocusState.h"
 10
 11 int yyFCparse();
 12 int yyFC_scan_bytes(const char *bytes, int len);
 13
 14 FocusStatePtr FocusParser::parse(const string &query)
 15 {
 16   // mutex lock for focus
 17   boost::mutex::scoped_lock lock(gFocusStateMutex);
 18
 19   // setup parse context
 20   gFocusState = FocusStatePtr(new FocusState());
 21
 22   yyFC_scan_bytes(query.data(), query.length());
 23
 24   yyFCparse();
 25
 26   // reset global state info
 27   FocusStatePtr result = gFocusState;
 28   gFocusState.reset();
 29
 30   return result;
 31 }

1 Answers1

0

On line 12 you have the declaration of yyFC_scan_bytes, which basically promises the compiler that it's OK to use the function with that singature, and that its definition will be provided later, probably at link time.

You are probably not linking your program with a valid definition of the function, hence the error message - your compiler has reserved a spot in your code where it wants to call the implementation of yyFC_scan_bytes, but you have not provided that implementation, and the linker is complaining about that.

DeducibleSteak
  • 1,398
  • 11
  • 23