Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:10:38+00:00 2026-05-23T16:10:38+00:00

I am using Flex and Bison to create a compiler. As I am trying

  • 0

I am using Flex and Bison to create a compiler. As I am trying to create an AST (Abstract Syntax Tree) for my program, I need to port it to C++. So far I have been successful, until a encountered a rather obscure error from my compiler:

Kraken.o: In function Kraken::FlexScanner::FlexScanner()':
Kraken.cc:(.text._ZN6Kraken11FlexScannerC2Ev[_ZN6Kraken11FlexScannerC5Ev]+0x26): undefined reference to vtable for Kraken::FlexScanner'
Kraken.o: In function Kraken::FlexScanner::~FlexScanner()':
Kraken.cc:(.text._ZN6Kraken11FlexScannerD2Ev[_ZN6Kraken11FlexScannerD5Ev]+0xb): undefined reference to vtable for Kraken::FlexScanner'

Here is all the relevant code:

Kraken.cc:

#include "KrakenScanner.hh"
#include "KrakenParser.hh"
int main(int argc, char * argv[]) {
    Kraken::Parser parser;
    return parser.parse();
}

KrakenScanner.hh:

#ifndef KRAKENSCANNER_HH_
#define KRAKENSCANNER_HH_
#if ! defined(yyFlexLexerOnce)
#include <FlexLexer.h>
#endif
#undef YY_DECL
#define YY_DECL int Kraken::FlexScanner::yylex()
#include "parser.hh"
namespace Kraken {
    class FlexScanner : public yyFlexLexer {
        public:
            int yylex(Kraken::BisonParser::semantic_type* lval);

        private:
            int yylex();
            Kraken::BisonParser::semantic_type* yylval;
    };
}

#endif /* KRAKENSCANNER_HH_ */

KrakenScanner.cc:

#include "KrakenScanner.hh"
int Kraken::FlexScanner::yylex(Kraken::BisonParser::semantic_type* lval) {
    yylval = lval; return yylex();
}

Makefile:

OBJS := Kraken.o parser.o scanner.o KrakenScanner.o KrakenParser.o
%.cc: %.y
    bison -o $(@:%.o=%.d) $<
%.cc: %.l
        flex -o$(@:%.o=%.d) -i $<
all: $(OBJS)
    g++ -okraken $(OBJS)
Kraken.o: Kraken.cc KrakenScanner.o KrakenParser.o
KrakenScanner.o: KrakenScanner.hh KrakenScanner.cc parser.o
parser.o: parser.hh parser.cc
parser.cc: parser.y
scanner.o: scanner.cc
scanner.cc: scanner.l
KrakenParser.o: KrakenParser.hh KrakenParser.cc KrakenScanner.o`

I don’t know if this will help, but FlexLexer.h defines the classes FlexLexer and yyFlexLexer. FlexLexer declares just a virtual destructor, and yyFlexLexer defines both a constructor and destructor. Also, when I attempt to overload the constr. and destr. in Kraken.cc, I get an error saying that the two are “implicitly defined”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:10:39+00:00Added an answer on May 23, 2026 at 4:10 pm

    Try a clean rebuild (rm *.o) and recompile. The compiler is supposed to generate this stuff automatically. Some compilers have special non-portable magic to influence v-table linking, but I don’t see anything like that in your code.


    Also, I see in your makefile that you’ve written a rule for linking with g++, but you haven’t written any rule for compilation. So make is using its built-in rules, which might by the C++ compiler provided by your OS, not g++.

    Another thing is that makefile rules should put the primary source first. For example:

    wrong:

     KrakenScanner.o: KrakenScanner.hh KrakenScanner.cc parser.o
    

    right:

     KrakenScanner.o: KrakenScanner.cc KrakenScanner.hh
    

    Finally, object files aren’t used to build other object files, only during linking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am developping a compiler using flex/bison. I have this warning in my build output.
Using Flex and Bison, I have a grammar specification for a boolean query language,
I would like to create simple C++ calculator using bison and flex. Please note
I am developing a simple compiler in the cygwin environment using flex and bison
I want to create a read-eval-print loop using flex/bison parser. Trouble is, the flex
I want to create a parser of template engine using Flex & Bison. The
I'm using Flex and Bison for a parser generator, but having problems with the
Using Flex 3, I have a Button which is skinned using PNGs specified in
Using Flex 3.2, I have a object which extends a TitleWindow. In this TitleWindow
I'm using Flex Builder more and more and attempting to create a fairly asset

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.