-
November 6th, 2012, 03:22 AM
#1
[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
-
November 6th, 2012, 07:32 AM
#2
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
-
November 6th, 2012, 07:37 AM
#3
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
-
November 6th, 2012, 09:06 AM
#4
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.
-
November 6th, 2012, 10:26 AM
#5
Re: [Newbie] SIP parser and header-file including (using sofia-sip)
Originally Posted by marcel_s
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|