antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.16k stars 3.28k forks source link

[C++] unresolved external symbol Guid::toString #2356

Open icedream2linxi opened 6 years ago

icedream2linxi commented 6 years ago

I compiled the dynamic library. When I use the interface for Guid, I get an error message "unresolved external symbo".

我编译了动态库。 当我使用了有关 Guid 的接口时,会有错误提示“unresolved external symbo”。

Example Code:

#include <stdio.h>
#include <antlr4-runtime.h>
using namespace antlr4;

int main()
{
    auto id = atn::ATNDeserializer::SERIALIZED_UUID();
    printf("%s\n", id.toString().c_str());

    GuidGenerator guidGnr;
    id = guidGnr.newGuid();
    printf("%s\n", id.toString().c_str());

    return 0;
}

Error:

1>ConsoleApplication_141_01.obj : error LNK2019: unresolved external symbol "public: class Guid & __cdecl Guid::operator=(class Guid const &)" (??4Guid@@QEAAAEAV0@AEBV0@@Z) referenced in function main
1>ConsoleApplication_141_01.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __cdecl Guid::toString(void)const " (?toString@Guid@@QEBA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function main
1>ConsoleApplication_141_01.obj : error LNK2019: unresolved external symbol "public: class Guid __cdecl GuidGenerator::newGuid(void)" (?newGuid@GuidGenerator@@QEAA?AVGuid@@XZ) referenced in function main
1>F:\TestProject\ConsoleApplication_141_01\x64\Debug\ConsoleApplication_141_01.exe : fatal error LNK1120: 3 unresolved externals
mike-lischke commented 5 years ago

You probably haven't compiled guid.cpp in your lib/app.