MainLexer.h in ‘Checker’ Project of static Library
class MainLexerFuncs
{
private:
static int run();
public:
static int start();
};
MainLexer.cpp in Checker Project of static Library which is using third party antlr tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.
#include “iostream”
using namespace std;
#include "HTMLLexer.hpp"
#include "HTMLParser.hpp"
#include "antlr/TokenBuffer.hpp"
#include "MainLexerLib.h"
#include “stdexcept”
using namespace std;
int MainLexerFuncs::run()
{
ANTLR_USING_NAMESPACE(std)
ANTLR_USING_NAMESPACE(antlr)
try {
HTMLLexer lexer(cin);
TokenBuffer buffer(lexer);
HTMLParser parser(buffer);
parser.document();
}
catch( ANTLRException& e )
{
cerr << "exception: " << e.getMessage() << endl;
return -1;
}
catch( exception& e )
{
cerr << "exception: " << e.what() << endl;
return -1;
}
cout<<"yes";
return 0;
}
int MainLexerFuncs::start(){
return MainLexerFuncs::run();
}
mainlexer.cpp in ‘MainChecker’ Project of Window Console Application in the same solution where Checker Projectc exists.
#include "iostream"
using namespace std;
#include "MainLexerLib.h"
int main( int, char** )
{
MainLexerFuncs::start();
return 0;
}
MainCheker is the windows console application which is using static library of Checker.lib that contains the file of MainLexer.h and MainLexer.cpp.
But when I run MainChecker then following error arrives:
1>------ Build started: Project: mainlexer, Configuration: Debug Win32 ------
1> mainlexer.cpp
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual __thiscall antlr::TokenBuffer::~TokenBuffer(void)" (??1TokenBuffer@antlr@@UAE@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::TokenBuffer::TokenBuffer(class antlr::TokenStream &)" (??0TokenBuffer@antlr@@QAE@AAVTokenStream@1@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::consume(void)" (?consume@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::consume(void)" (?consume@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::panic(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?panic@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::panic(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?panic@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::panic(void)" (?panic@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::panic(void)" (?panic@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportError(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportError@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportError(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportError@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportError(class antlr::RecognitionException const &)" (?reportError@CharScanner@antlr@@UAEXABVRecognitionException@2@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportError(class antlr::RecognitionException const &)" (?reportError@CharScanner@antlr@@UAEXABVRecognitionException@2@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportWarning(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportWarning@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::reportWarning(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportWarning@CharScanner@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceIndent(void)" (?traceIndent@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceIndent(void)" (?traceIndent@CharScanner@antlr@@UAEXXZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceIn(char const *)" (?traceIn@CharScanner@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceIn(char const *)" (?traceIn@CharScanner@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceOut(char const *)" (?traceOut@CharScanner@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::CharScanner::traceOut(char const *)" (?traceOut@CharScanner@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: bool __thiscall antlr::BitSet::member(unsigned int)const " (?member@BitSet@antlr@@QBE_NI@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: bool __thiscall antlr::BitSet::member(unsigned int)const " (?member@BitSet@antlr@@QBE_NI@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: bool __thiscall antlr::BitSet::member(unsigned int)const " (?member@BitSet@antlr@@QBE_NI@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,int,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HH_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,int,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HH_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::BitSet::~BitSet(void)" (??1BitSet@antlr@@QAE@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::BitSet::~BitSet(void)" (??1BitSet@antlr@@QAE@XZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::BitSet::~BitSet(void)" (??1BitSet@antlr@@QAE@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::toString(void)const " (?toString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::toString(void)const " (?toString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::toString(void)const " (?toString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::MismatchedCharException::getMessage(void)const " (?getMessage@MismatchedCharException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::MismatchedCharException::getMessage(void)const " (?getMessage@MismatchedCharException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::getFileLineColumnString(void)const " (?getFileLineColumnString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::getFileLineColumnString(void)const " (?getFileLineColumnString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::RecognitionException::getFileLineColumnString(void)const " (?getFileLineColumnString@RecognitionException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,class antlr::BitSet,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HVBitSet@1@_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,class antlr::BitSet,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HVBitSet@1@_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,int,int,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HHH_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::MismatchedCharException::MismatchedCharException(int,int,int,bool,class antlr::CharScanner *)" (??0MismatchedCharException@antlr@@QAE@HHH_NPAVCharScanner@1@@Z)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: virtual __thiscall antlr::Parser::~Parser(void)" (??1Parser@antlr@@UAE@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual __thiscall antlr::Parser::~Parser(void)" (??1Parser@antlr@@UAE@XZ)
1>CheckLexer.lib(MainLexerLib.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::ASTRef::~ASTRef(void)" (??1ASTRef@antlr@@QAE@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::ASTRef::~ASTRef(void)" (??1ASTRef@antlr@@QAE@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::LLkParser::LLkParser(class antlr::TokenBuffer &,int)" (??0LLkParser@antlr@@QAE@AAVTokenBuffer@1@H@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::consumeUntil(class antlr::BitSet const &)" (?consumeUntil@Parser@antlr@@UAEXABVBitSet@2@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::consumeUntil(int)" (?consumeUntil@Parser@antlr@@UAEXH@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::match(class antlr::BitSet const &)" (?match@Parser@antlr@@UAEXABVBitSet@2@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::match(int)" (?match@Parser@antlr@@UAEXH@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::matchNot(int)" (?matchNot@Parser@antlr@@UAEXH@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::reportError(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportError@Parser@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::reportError(class antlr::RecognitionException const &)" (?reportError@Parser@antlr@@UAEXABVRecognitionException@2@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::reportWarning(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reportWarning@Parser@antlr@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::panic(void)" (?panic@Parser@antlr@@UAEXXZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::Parser::traceIndent(void)" (?traceIndent@Parser@antlr@@UAEXXZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::LLkParser::traceIn(char const *)" (?traceIn@LLkParser@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall antlr::LLkParser::traceOut(char const *)" (?traceOut@LLkParser@antlr@@UAEXPBD@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: unsigned int __thiscall antlr::TokenBuffer::mark(void)" (?mark@TokenBuffer@antlr@@QAEIXZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: void __thiscall antlr::TokenBuffer::rewind(unsigned int)" (?rewind@TokenBuffer@antlr@@QAEXI@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: int __thiscall antlr::TokenBuffer::LA(unsigned int)" (?LA@TokenBuffer@antlr@@QAEHI@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: class antlr::RefCount<class antlr::Token> __thiscall antlr::TokenBuffer::LT(unsigned int)" (?LT@TokenBuffer@antlr@@QAE?AV?$RefCount@VToken@antlr@@@2@I@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::LLkParser::LLkParser(class antlr::TokenStream &,int)" (??0LLkParser@antlr@@QAE@AAVTokenStream@1@H@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::LLkParser::LLkParser(class antlr::RefCount<class antlr::ParserInputState> const &,int)" (??0LLkParser@antlr@@QAE@ABV?$RefCount@VParserInputState@antlr@@@1@H@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::NoViableAltException::NoViableAltException(class antlr::RefCount<class antlr::Token>,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0NoViableAltException@antlr@@QAE@V?$RefCount@VToken@antlr@@@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::NoViableAltException::getMessage(void)const " (?getMessage@NoViableAltException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: static struct antlr::ASTRef * __cdecl antlr::ASTRef::getRef(class antlr::AST const *)" (?getRef@ASTRef@antlr@@SAPAU12@PBVAST@2@@Z)
1>CheckLexer.lib(HTMLParser.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::BitSet::BitSet(unsigned long const *,unsigned int)" (??0BitSet@antlr@@QAE@PBKI@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::BitSet::BitSet(unsigned long const *,unsigned int)" (??0BitSet@antlr@@QAE@PBKI@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::CharScanner::CharScanner(class antlr::InputBuffer *,bool)" (??0CharScanner@antlr@@QAE@PAVInputBuffer@1@_N@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::CharBuffer::CharBuffer(class std::basic_istream<char,struct std::char_traits<char> > &)" (??0CharBuffer@antlr@@QAE@AAV?$basic_istream@DU?$char_traits@D@std@@@std@@@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::CharScanner::CharScanner(class antlr::InputBuffer &,bool)" (??0CharScanner@antlr@@QAE@AAVInputBuffer@1@_N@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::CharScanner::CharScanner(class antlr::RefCount<class antlr::LexerInputState> const &,bool)" (??0CharScanner@antlr@@QAE@ABV?$RefCount@VLexerInputState@antlr@@@1@_N@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "class antlr::RefCount<class antlr::Token> antlr::nullToken" (?nullToken@antlr@@3V?$RefCount@VToken@antlr@@@1@A)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: __thiscall antlr::NoViableAltForCharException::NoViableAltForCharException(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,int)" (??0NoViableAltForCharException@antlr@@QAE@HABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HH@Z)
1>CheckLexer.lib(HTMLLexer.obj) : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall antlr::NoViableAltForCharException::getMessage(void)const " (?getMessage@NoViableAltForCharException@antlr@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>D:\Lexer\CheckLexer\Debug\mainlexer.exe : fatal error LNK1120: 51 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*/
Please tell me how can I resolve it? I will be thanful to you.
Building static library (CheckLexer.lib), you don’t need to have all dependencies resolved – this is how static libraries are built.
But you need to resolve these used dependencies when building final binary (executable). So you need to link your executable against antlr library.
You are probably missing appropriate entry (antlr.lib?) in the ‘Linker > Input > Additional Dependencies’ settings for your executable project.