{{{ #!html
}}} = Developing PJSIP with Eclipse = '''Table of Contents''' [[PageOutline(2-3,,inline)]] 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. [[BR]] == 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. [[BR]] == Getting and Configuring PJSIP == 1. Download and install PJSIP [wiki:Getting-Started/Download-Source 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''' [[BR]] == Setting Up Eclipse == 1. Run Eclipse 1. Configure workspace: - Create/select a directory for your workspace the first time you run Eclipse. This directory should be placed outside your PJPROJECT directory. 1. Disable auto-build everytime something changes: - Uncheck '''Project''' --> '''Build Automatically''' 1. 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. 1. 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) 1. 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 [[BR]] == Importing PJSIP == To import PJSIP into your Eclipse workspace: 1. Create a new project for PJPROJECT: 1. Select '''File''' --> '''New''' --> '''C Project''' menu. 1. 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''' 1. Click '''Finish''' 1. You should now see your project in the ''Project Explorer'' pane. [[BR]] == 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 += }}} 1. Other customizations can be put in '''config_site.h''' as usual. [[BR]] == Debugging the Project == 1. Don't forget to put '''-g''' flag in your '''user.mak''' and possibly remove any optimization flags. 1. Don't forget to run '''make dep''' once, otherwise dependencies wouldn't have been set correctly. 1. Build the project 1. Create a new Debug configuration for each executable that you want to debug: 1. Open '''Run''' --> '''Debug Configurations''' 1. Select '''C/C++ Application''' from the left tree pane, and press '''New''' button 1. Edit the Debug Configuration: 1. Name: '''pjsua''' (for example) 1. 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) 1. Go to Debugger tab: - if Debugger is not set, select '''gdb/mi''' - uncheck '''Stop on startup at..''' 1. Click Apply 1. Click '''Debug''' to start debugging 1. You may set breakpoints, inspect variables, step into/over, etc. as you would expect from a decent IDE. [[BR]] == 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. {{{ #!html
}}}