[Newbie] SIP parser and header-file including (using sofia-sip)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: [Newbie] SIP parser and header-file including (using sofia-sip)

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    [Newbie] SIP parser and header-file including (using sofia-sip)

    Hi all,

    I am currently developing a small quick'n dirty SIP (Session Initiation Protocol) parser. Its task is to read a file (or command-line argument) with a SIP requst and parse it using the sofia-sip library. It should exit either with "1" on parsing failure or "0" on parsing success.

    I am a newbie regarding c++ and have taken the code snipplet from here: http://thread.gmane.org/gmane.comp.t...660/focus=2662 resulting in this source code:

    Code:
    #include <iostream>
    #include <stdio.h>  
    #include <sofia-sip/msg.h>  
    #include <sofia-sip/msg_parser.h>
    #include <sofia-sip/msg_mclass.h>
    
    int main()
    {
      char *msg_data = "...";
      msg_t* msg = msg_make (sip_default_mclass(), 0, msg_data,sizeof (msg_data));
      if (!msg) {
        fprintf(stderr, "Impossible to parse message\n");
        return 1;
      }else{
        fprintf(stderr, "Successful message parsing\n");
        return 0;
      }
    }
    When I try to compile the code using
    Code:
    g++ -o parser -I/usr/include/sofia-sip-1.12 parser.cpp
    , I get the following failure:

    Code:
    parser.cpp:10:45: error: ‘sip_default_mclass’ was not declared in this scope
    Ehm, now I am completely stucked and I would appreciate any help,

    thx and br
    Marcel

  2. #2
    Join Date
    Jan 2009
    Posts
    1,689

    Re: [Newbie] SIP parser and header-file including (using sofia-sip)

    You need to link to the sip library binaries.

    g++ -o parser -I/usr/include/sofia-sip-1.12 parser.cpp -lsofia-sip-1.12

  3. #3
    Join Date
    Nov 2012
    Posts
    2

    Re: [Newbie] SIP parser and header-file including (using sofia-sip)

    Hm, thanks for your response, but the error stays the same:

    Code:
     marcel@hades:~/tools/sipparser$ g++ -o parser -I/usr/include/sofia-sip-1.12 parser.cpp -lsofia-sip
    parser.cpp: In function ‘int main()’:
    parser.cpp:9:20: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    parser.cpp:10:45: error: ‘sip_default_mclass’ was not declared in this scope
    Any other idea?

    br
    Marcel

  4. #4
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,109

    Re: [Newbie] SIP parser and header-file including (using sofia-sip)

    You are most likely missing a header file where the struct/class/whatever sip_default_mclass is declared.

  5. #5
    Join Date
    Apr 1999
    Posts
    27,427

    Re: [Newbie] SIP parser and header-file including (using sofia-sip)

    Quote Originally Posted by marcel_s View Post
    Hm, thanks for your response, but the error stays the same:
    The error is not a linker error, it is a compiler error. Adding library binaries will not fix the problem that you're having, since libraries only come into play at the link (not compile) stage of building the application.

    The error is simple -- the compiler is stating that it has no idea what a "sip_default_mclass" is. This indicates that the definition is either in a missing header file, or the definition has been "commented out" prior to you referring to it using #ifdef or some other preprocessor directive.

    So your job is to find where "sip_default_mclass" is declared, and verify it is being #included and has not been preprocessed away.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center