wiki:Using_Eclipse_with_PJSIP

Version 2 (modified by bennylp, 14 years ago) (diff)

--

Developing PJSIP with Eclipse

Table of Contents

  1. Getting and Installing Eclipse
  2. Getting and Configuring PJSIP
  3. Setting Up Eclipse
  4. Importing PJSIP
  5. Customizing PJSIP
  6. Debugging the Project
  7. Problems and Solutions
    1. I have not been able to set breakpoints
    2. When I step into/over the code, the execution moves erraticly

This short article shows how to use Eclipse for PJSIP development on Linux platform. Using Eclipse one can enjoy Visual Studio like experience in developing PJSIP.


Getting and Installing Eclipse

  1. Download Eclipse for C++ Developers for your platform from http://www.eclipse.org/downloads/.
    • Even on Linux/Ubuntu you'd better off getting and installing Eclipse this way instead of with Package Manager, since as far as I know Eclipse C++ plug-in is not available from the repository (as of Ubuntu 09.10) and installing plug-in manually is rather cumbersome as you'd need to run Eclipse as root.
  2. Installation is straightforward, just unpack the tarball containing eclipse directory to your preferred directory, such as/opt, and run the eclipse executable directly.
    • sudo as root as necessary to write to /opt directory.
  3. You will have to install a Java Run-time Environment if you haven't had one. On Ubuntu, just install default-jre package.


Getting and Configuring PJSIP

  1. Download and install PJSIP as usual.
  2. Configure PJSIP with minimal setting, e.g.:
    $ ./aconfigure CFLAGS='-Wno-unused-label'
    
    The reason for the minimal setting is because we want to configure as much possible from Eclipse instead of having to re-run ./aconfigure every time some compilation flags need to be changed. The way to do this (later) is to put your customization in user.mak file instead.
  3. Do a make dep


Setting Up Eclipse

  1. Run Eclipse
  2. Configure workspace:
    • Create/select a directory for your workspace the first time you run Eclipse. This directory should be placed outside your PJPROJECT directory.
  3. Disable auto-build everytime something changes:
    • Uncheck Project --> Build Automatically
  4. Set proper indentation for PJSIP:
    • Select menu:
      • Linux: Window --> Preferences
      • Mac: Eclipse --> Preferences
    • In the Preferences dialog, from the tree, select C/C++ --> Code Style
    • in the code style, press New:
      • Profile name: pjsip
      • Initialize settings with the following profile: K&R [built-in]
      • Click OK
    • in the pjsip profile editing dialog:
      • Tab policy: mixed
      • Uncheck Use tabs only
      • Indentation: 4
      • Tab size: 8
      • Click OK to close pjsip profile editing dialog
    • Click OK to close Preferences dialog.
  5. To activate Visual Studio style key shortcuts:
    • Select menu:
      • Linux: Window --> Preferences
      • Mac: Eclipse --> Preferences
    • In the Preferences dialog, from the tree, select General --> Keys
    • Select Microsoft Visual Studio scheme
    • Customize other key shortcuts as wanted (for example, F7 for Build)
  6. Disable menubar F10 acceleration key, as we need the F10 to be captured by Eclipse (Visual Studio users use F10 for stepping to next statement during debugging):
    • Ubuntu/Gnome:
      • On Gnome, F10 key will open application's menubar, even if it has been assigned to other thing with Eclipse (for example, Step Over with Visual Studio keys)
      • To disable F10 from popping up the application menu, open terminal and run:
        $ gconftool-2 -s --type string /desktop/gnome/interface/menubar_accel 'F12'
        
        Basically the command above assigns menubar acceleration key to something other than F10, in this case F12 key
    • Mac:
      • System Preference --> Keyboard & Mouse --> Keyboard shortcuts
      • Uncheck F10


Importing PJSIP

To import PJSIP into your Eclipse workspace:

  1. Create a new project for PJPROJECT:
    1. Select File --> New --> C Project menu.
    2. In the C Project dialog:
      • Project name: pjproject
      • Uncheck Use default location checkbox
      • Location: set to the location of you PJPROJECT installation
      • Project type: Makefile project --> Empty Project
      • Toolchains: Linux GCC
    3. Click Finish
  2. You should now see your project in the Project Explorer pane.


Customizing PJSIP

  1. Compile time customizations can be put in user.mak file in your root PJPROJECT directory. Example of a user.mak file content:
    export CFLAGS += -g
    export LDFLAGS +=
    
  2. Other customizations can be put in config_site.h as usual.


Debugging the Project

  1. Don't forget to put -g flag in your user.mak and possibly remove any optimization flags.
  2. Don't forget to run make dep once, otherwise dependencies wouldn't have been set correctly.
  3. Build the project
  4. Create a new Debug configuration for each executable that you want to debug:
    1. Open Run --> Debug Configurations
    2. Select C/C++ Application from the left tree pane, and press New button
    3. Edit the Debug Configuration:
      1. Name: pjsua (for example)
      2. For the C/C++ Application, click Search Project and select the pjsua executable from there (that's why you need to build the project first)
      3. Go to Debugger tab:
        • if Debugger is not set, select gdb/mi
        • uncheck Stop on startup at..
      4. Click Apply
    4. Click Debug to start debugging
  5. You may set breakpoints, inspect variables, step into/over, etc. as you would expect from a decent IDE.


Problems and Solutions

I have not been able to set breakpoints

Make sure the project is built with debugging flag (i.e. "-g")

When I step into/over the code, the execution moves erraticly

Make sure optimization flag is turned off.