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 8074921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:49:21+00:00 2026-06-05T14:49:21+00:00

I have a project with automake build system and there are flex/bison files there.

  • 0

I have a project with automake build system and there are flex/bison files there. Now I can’t understand how to include them into cmake build system. I’m trying to do this manually. Here is the project tree:

+ROOT
|---CMakeLists.txt
|---Sources/
|   |---Flex
|   |---Main
|   |---CMakeLists.txt
|---Includes/

In Flex folder there are 2 files: player_command_parser.ypp; player_command_tok.lpp. These files are from RoboCup soccer server.

I don’t really know how to use them with new build system so I decided to generate all files manually by hands:

flex --c++ player_command_tok.lpp 

This command generates lex.RCSSPCom.cc which starts with the following code:

#line 3 "lex.RCSSPCom.cc"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

    /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
     * following macro. This is required in order to pass the c++-multiple-scanners
     * test in the regression suite. We get reports that it breaks inheritance.
     * We will address this in a future release of flex, or omit the C++ scanner
     * altogether.
     */
    #define yyFlexLexer RCSSPComFlexLexer

The next step is: bison -d player_command_parser.ypp.

I got: player_command_parser.tab.cpp; player_command_parser.tab.hpp

Now I’m trying to copy all generated files to related folders: *.tab.hpp -> Includes, and added cc&cpp files into Sources/CMakeLists.txt:

set (FlexSources
    Server/Flex/lex.RCSSPCom.cc
    Server/Flex/player_command_parser.tab.cpp
)

And the compile output:

[  1%] Building CXX object Sources/Flex/lex.RCSSPCom.cc.o
In file included from /Includes/player_command_tok.h:31:0,
                 from player_command_tok.lpp:28:
/usr/include/FlexLexer.h:112:7: error: redefinition of ‘class RCSSPComFlexLexer’
/usr/include/FlexLexer.h:112:7: error: previous definition of ‘class RCSSPComFlexLexer’

What could be wrong?

  • 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-06-05T14:49:22+00:00Added an answer on June 5, 2026 at 2:49 pm

    Your compile error appears to be due to some header being included twice. You may need to make an extra file that is little more than an include guard:

    player_command_tok_guarded.hpp:

    #ifndef PLAYER_COMMAND_TOK_GUARDED
    #define PLAYER_COMMAND_TOK_GUARDED
    #include "player_command_tok.hpp"
    #endif
    

    And make your files #include this new file instead. As to integrating flex and bison into your CMake system, try something like this:

    # Find flex and bison.
    find_program(FLEX flex DOC "Path to the flex lexical analyser generator.")
    if(NOT ${FLEX})
      message(SEND_ERROR "Flex not found.")
    endif
    find_program(BISON bison DOC "Path to the bison parser generator.")
    if(NOT ${BISON})
      message(SEND_ERROR "Bison not found.")
    endif
    
    # Custom commands to invoke flex and bison.
    add_custom_command(OUTPUT lex.RCSSPCom.cc
                       COMMAND ${FLEX} --c++ player_command_tok.lpp 
                       MAIN_DEPENDENCY player_command_tok.lpp
                       COMMENT "Generating lexer"
                       VERBATIM)
    add_custom_command(OUTPUT player_command_parser.tab.cpp player_command_parser.tab.hpp
                       COMMAND ${BISON} -d player_command_parser.ypp
                       MAIN_DEPENDENCY player_command_parser.ypp
                       COMMENT "Generating parser"
                       VERBATIM)
    

    And add the files to your file list as usual.

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

Sidebar

Related Questions

Problem: I have a project which I'm porting from Solaris/Lex/Yacc to Linux/Flex/Bison + Autotools.
I have a project that I want to build using automake. The project consists
I created an Android project a few months ago and now have to automate
I am very desperate now... I have project in Visual C++ 2010 using Qt
I have a project where I have folders, subfolders, and files. I need to
I have a project involving a web voting system. The current values and related
In an Arduino project, I have build configurations to compile for, and download to,
I have some code to automate the creation of build definitions in TFS. Now
I have access to a large C++ project, full of files and with a
I have a Maven project that uses the jaxb2-maven-plugin to compile some xsd files.

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.