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

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;

}

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] lists.digium.com/mailman/listinfo/asterisk-dev

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.

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.