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

  • Home
  • SEARCH
  • 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 9192161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:51:24+00:00 2026-06-17T20:51:24+00:00

Although Undefined Reference error questions have been asked several times, I couldn’t find solution

  • 0

Although “Undefined Reference error” questions have been asked several times, I couldn’t find solution to my problem.

I am trying to get flex and bison to work in a Qt app. I am facing problem in linking only.

These are the relevant files-

1) icd.l – Lex specification – It generates iclexer.c and contains definition of functions-

void yyerror(char const *s){...}
void* setUpBuffer(char const* text){...}
void tearDownBuffer(void* buffer){...}
int nextToken(){...}

2) iclexer.h

#ifndef ICLEXER_H
#define ICLEXER_H

extern void  yyerror(char const *);
extern int   yylex();
extern char* yytext;
extern void* setUpBuffer(char const* text);
extern void  tearDownBuffer(void* buffer);
extern int nextToken();

#endif // ICLEXER_H

3) icparser.h

#ifndef ICPARSER_H
#define ICPARSER_H
#include "iclexer.h"
#include <string>

extern void initLexer(std::string const& t);
extern void clearLexer();
extern int yyparse();

class Parser
{
public:
    Parser(std::string const& s)
    {
        initLexer(s);
    }
    void parse()
    {
        yyparse();
    }
    ~Parser()
    {
        clearLexer();
    }
};
#endif // ICPARSER_H

4) icd.y – Bison specification – It generates icparser.cpp and contains definition of functions-

void initLexer(std::string const& t);
void clearLexer();
int yylex();

In my GUI code I include icparser.h and use class Parser‘s interface. But I am getting following error-

/home/vinayak/codes/qt/dic_sim/icparser.cpp:1402:
error: undefined reference to `yyerror(char const*)’

And similar errors for setUpBuffer(char const* text);, tearDownBuffer(void* buffer); and nextToken();. Basically the functions in iclexer.c are not getting linked properly.

Please tell me how to either modify this code or how to change linking order in Qt (Qt Creator)?

  • 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-17T20:51:25+00:00Added an answer on June 17, 2026 at 8:51 pm

    If the generated header file is exactly as stated, i.e. without any extern "C" then the problem you might be facing is that the C compiler will generate an unmangled symbol when compiling the function, but the C++ compiler will generate a dependency to the mangled name. The linker will see the dependency and the symbol, but not having the same name it will fail to match them together.

    Take a look at the documentation of the tool used to generate the code and find how to generate C++ compatible code (usually just requires the inclusion of extra extern "C" code in the headers).

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

Sidebar

Related Questions

Although I have found some solutions to this problem, none of them refer to
Although I have read a few previously answered questions regarding a similar issue, I
I have this code and it's giving me an undefined error if country is
i am having a problem, i am receiving an error which says undefined variable
although I saw this problem in other blogs, I couldn't make it works in
I have several iFrames that load an external webpage, although only 1 appears at
I have tried to answer this myself, by looking up several questions at StackOverflow.
Although this code is from an algorithm text, I have a bit of a
Although I have set pyramid.reload_templates to true e.g. pyramid.reload_templates = true , each time
Although I know the basic concepts of binary representation, I have never really written

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.