Author Topic: Why can't I define a NativeParser object?  (Read 5171 times)

Offline bruce

  • Multiple posting newcomer
  • *
  • Posts: 13
Why can't I define a NativeParser object?
« on: April 07, 2012, 04:27:22 am »
I'd like define a NativeParser object to help me to parse a specific file and get the information I need. But the compiler tells me that my definition has something wrong.I am confused.
    The code of the key part is as follows.

Code
#include "G:\codeblocks-10.05-release\src\plugins\codecompletion\nativeparser.h"
void myHello::OnMyHello(wxCommandEvent &event)
{
    LogManager* lm = Manager::Get()->GetLogManager();
    NativeParser np;

    Parser *par = np.GetParserPtr();
    par->Parse(_("E:\\PolynomialProblem(HDOJ).cpp")); //I want to use the parser to parse the specific file.

    //to process the parsing results;
    TokensTree * tt = par->GetTokens();
    for(int i=0; i<tt->size(); ++i)
    {
    Token* t = tt->at(i);
    lm->Log(t->m_Name); //to output the useful information to the CB.
    }
}


And the compiler logs are as follows.
Code
Compiling: myHello.cpp
Linking dynamic library: myHello.dll
.objs\myHello.o:E:/C盘/hello/myHello.cpp:177: undefined reference to `NativeParser::NativeParser()'
.objs\myHello.o:E:/C盘/hello/myHello.cpp:180: undefined reference to `Parser::Parse(wxString const&, bool, LoaderBase*)'
.objs\myHello.o:E:/C盘/hello/myHello.cpp:183: undefined reference to `TokensTree::size()'
.objs\myHello.o:E:/C盘/hello/myHello.cpp:187: undefined reference to `NativeParser::~NativeParser()'
.objs\myHello.o:E:/C盘/hello/myHello.cpp:187: undefined reference to `NativeParser::~NativeParser()'
.objs\myHello.o:G:/codeblocks-10.05-release/src/plugins/codecompletion/parser/token.h:156: undefined reference to `TokensTree::GetTokenAt(int)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
6 errors, 0 warnings

    I have read the source files of the codecompletion plugin for some time. Maybe I didn't master this classes well. I need your suggestions. ???

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Why can't I define a NativeParser object?
« Reply #1 on: April 07, 2012, 07:42:57 am »
1,
Quote
undefined reference to `NativeParser::NativeParser()'
You should have some cpp file in your project, like nativeparser.cpp.
BTW: I can try to see parser test project as a reference.
/src/plugins/codecompletion/parser/parsertest.cbp

2, Chinese chars in your path may cause some compiler error. So I suggest avoid this.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Why can't I define a NativeParser object?
« Reply #2 on: April 07, 2012, 09:10:47 am »
bruce:
Keep in mind that this code is not part of the public SDK and might change without notice.
The code for the plublic SDK is in src/include and src/sdk/.
All the other code is privet in regard to plugin writers.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]