Hello!
I hope, I'm doing this right with the mailing list, otherwise I want to
apologise!
I wanted to run the "hello world" from
http://gitorious.org/sofia-sip/pages/SofiaTutorial with hello.c:
/* Hello world in Sofia-SIP.
*
* This application will send a MESSAGE
* from <sip:localhost:5062> to <sip:localhost:5060>
*/
#include <stdio.h>
#include <sofia-sip/nua.h>
void send_message (nua_t *nua);
void event_callback(nua_event_t event,
int status,
char const *phrase,
nua_t *nua,
nua_magic_t *magic,
nua_handle_t *nh,
nua_hmagic_t *hmagic,
sip_t const *sip,
tagi_t tags[]);
int
main (int argc, char *argv[])
{
su_root_t *root;
nua_t *nua;
/* Initialize Sofia-SIP library and create event loop */
su_init ();
root = su_root_create (NULL);
/* Create a user agent instance. Caller and callee should bind to different
* address to avoid conflicts. The stack will call the 'event_callback()'
* callback when events such as succesful registration to network,
* an incoming call, etc, occur.
*/
nua = nua_create(root, /* Event loop */
event_callback, /* Callback for processing events */
NULL, /* Additional data to pass to callback */
#ifdef CALLER
NUTAG_URL("sip:0.0.0.0:5062"), /* Address to bind to */
#else
NUTAG_URL("sip:0.0.0.0:5060"),
#endif
TAG_END()); /* Last tag should always finish the sequence */
#ifdef CALLER
send_message (nua);
#endif
/* Run event loop */
su_root_run (root);
/* Destroy allocated resources */
nua_destroy (nua);
su_root_destroy (root);
su_deinit ();
return 0;
}
/* This callback will be called by SIP stack to
* process incoming events
*/
void event_callback(nua_event_t event,
int status,
char const *phrase,
nua_t *nua,
nua_magic_t *magic,
nua_handle_t *nh,
nua_hmagic_t *hmagic,
sip_t const *sip,
tagi_t tags[])
{
printf ("Hello world!\n"
"I have received an event %s status %d %s\n",
nua_event_name (event), status, phrase);
}
/* Create a communication handle, send MESSAGE with it and destroy it */
void send_message (nua_t *nua)
{
nua_handle_t *handle;
handle = nua_handle(nua, NULL, SIPTAG_TO_STR("sip:test@127.0.0.1:5060"),
TAG_END());
nua_message(handle,
SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR("Hello callee!!!"),
TAG_END());
nua_handle_destroy (handle);
}
and the makefile:
CFLAGS = -g -O0
all: hello-caller hello-callee
hello-caller: hello.c
gcc `pkg-config sofia-sip-ua --cflags --libs` -DCALLER $(CFLAGS) -o
hello-caller hello.c
hello-callee: hello.c
gcc `pkg-config sofia-sip-ua --cflags --libs` $(CFLAGS) -o hello-callee
hello.c
clean:
rm hello-caller hello-callee
I use Ubuntu on a VirtualBox (4.0.8 r71778) and have installed sofia sip with
./configure, make and make install.
Afterwards some symbolic links were set:
ln -s /usr/local/lib/pkgconfig/sofia-sip-ua.pc
/usr/lib/pkgconfig/sofia-sip-ua.pc
ln -s /usr/local/lib/pkgconfig/sofia-sip-ua-glib.pc
/usr/lib/pkgconfig/sofia-sip-ua-glib.pc
When I want to run make of hello world, then the following errors are shown:
~/Sofia_SIP/Wrapper/HelloSofiaSIP$ make
gcc `pkg-config sofia-sip-ua --cflags --libs` -DCALLER -L/usr/local/lib
/usr/local/lib/libsofia-sip-ua.so -g -O0 -o hello-caller hello.c
/tmp/cc1aUs3N.o: In function `main':
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:30: undefined reference to
`su_init'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:31: undefined reference to
`su_root_create'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:38: undefined reference to
`nutag_url'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:38: undefined reference to
`nua_create'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:53: undefined reference to
`su_root_run'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:56: undefined reference to
`nua_destroy'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:57: undefined reference to
`su_root_destroy'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:58: undefined reference to
`su_deinit'
/tmp/cc1aUs3N.o: In function `event_callback':
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:76: undefined reference to
`nua_event_name'
/tmp/cc1aUs3N.o: In function `send_message':
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:86: undefined reference to
`siptag_to_str'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:86: undefined reference to
`nua_handle'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:88: undefined reference to
`siptag_payload_str'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:88: undefined reference to
`siptag_content_type_str'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:88: undefined reference to
`nua_message'
/home/user/Sofia_SIP/Wrapper/HelloSofiaSIP/hello.c:93: undefined reference to
`nua_handle_destroy'
collect2: ld returned 1 exit status
make: *** [hello-caller] Error 1
Could it be that it's a linking problem, maybe something has to be added to the
makefile or some links have to be set?!
Please answer if you have any suggestions!
Thanks in advance!
Regards, shaeur
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel