Using PJSIP in applications

  1. Build pjproject.

  2. Create application source directory (outside the PJSIP sources).

  3. Create a sample myapp.c:

    #include <pjsua-lib/pjsua.h>
    #include <pj/log.h>
    
    int main()
    {
       pj_status_t status;
    
       status = pjsua_create();
       PJ_LOG(3,("myapp.c", "Hello PJSIP! Bye PJSIP."));
       pjsua_destroy();
       return 0;
    }
    
  4. Create Makefile for the sample application:

    PJDIR = /path/to/pjproject
    include $(PJDIR)/build.mak
    
    myapp: myapp.o
            $(PJ_CC) -o $@ $< $(PJ_LDFLAGS) $(PJ_LDLIBS)
    
    myapp.o: myapp.c
            $(PJ_CC) -c -o $@ $< $(PJ_CFLAGS)
    
    clean:
            rm -f myapp.o myapp
    

    Note

    Replace PJDIR with path to pjproject source tree.

    Alternatively, if make install was run (on PJSIP) and if pkg-config tool is available, you can use pkg-config --cflags --libs --static libpjproject

  5. Run make.