how to add c++ program to asterisk app module ?

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

how to add c++ program to asterisk app module ?

Postby nwcoaster6 » Tue Jan 05, 2016 2:09 am

static int myapp_exec(struct ast_channel *chan, void *data)
{

int res=0;



return res;

}

// a.cpp

int main(void)
{


cout << "hello" << endl;
while(1)
{
sleep (60);
}


return 0;

}
nwcoaster6
Newsterisk
 
Posts: 6
Joined: Tue Jan 05, 2016 1:41 am

Re: how to add c++ program to asterisk app module ?

Postby jcolp » Tue Jan 05, 2016 6:26 am

I'd suggest using the asterisk-dev mailing list[1] for this type of question. Generally though while you can use C++ itself in modules it's not commonly used. As well you can't have a standalone program execute within Asterisk like you normally would. There's entry points that Asterisk will call into to tell your module to start and such, so you can create a thread and do stuff. You can't have a main though.

[1] http://lists.digium.com/mailman/listinfo/asterisk-dev
Joshua Colp
Digium, Inc. | Senior Software Developer
jcolp
Oldsterisk
 
Posts: 248
Joined: Tue May 19, 2015 6:59 am

Re: how to add c++ program to asterisk app module ?

Postby jcolp » Wed Jan 06, 2016 6:35 am

Additional files can be built and linked in using something like the following in the Makefile:

app_test.so: test/first.o test/second.o

I also strongly urge you to use the asterisk-dev mailing list.
Joshua Colp
Digium, Inc. | Senior Software Developer
jcolp
Oldsterisk
 
Posts: 248
Joined: Tue May 19, 2015 6:59 am

Re: how to add c++ program to asterisk app module ?

Postby david55 » Wed Jan 06, 2016 4:51 pm

As well as agreeing that this forum is the wrong place, I would suggest that insisting on using C++ will only cause you unnecessary hassle. Asterisk is object oriented code, but is not written in an specifically object oriented language.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am


Return to Asterisk Support

Who is online

Users browsing this forum: No registered users and 11 guests