Changes between Initial Version and Version 1 of Using_Eclipse_with_PJSIP


Ignore:
Timestamp:
Aug 20, 2010 11:57:13 AM (14 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Using_Eclipse_with_PJSIP

    v1 v1  
     1{{{ 
     2#!html 
     3<!-- MAIN TABLE START --> 
     4<table border=0 width="90%" align="center"><tr><td> 
     5}}} 
     6 
     7= Developing PJSIP with Eclipse = 
     8 
     9'''Table of Contents''' 
     10[[PageOutline(2-3,,inline)]] 
     11 
     12This 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. 
     13 
     14[[BR]] 
     15 
     16== Getting and Installing Eclipse == 
     17 
     18 1. Download ''Eclipse for C++ Developers'' for your platform from http://www.eclipse.org/downloads/.  
     19    - 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. 
     20 2. Installation is straightforward, just unpack the tarball containing ''eclipse'' directory to your preferred directory, such as'''/opt''', and run the '''eclipse''' executable directly. 
     21    - sudo as root as necessary to write to /opt directory. 
     22 3. You will have to install a ''Java Run-time Environment'' if you haven't had one. On Ubuntu, just install '''default-jre''' package. 
     23 
     24[[BR]] 
     25 
     26== Getting and Configuring PJSIP == 
     27 
     28 1. Download and install PJSIP [wiki:Getting-Started/Download-Source as usual]. 
     29 2. Configure PJSIP with minimal setting, e.g.: 
     30   {{{ 
     31$ ./aconfigure CFLAGS='-Wno-unused-label' 
     32   }}} 
     33 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. 
     34 3. Do a '''make dep''' 
     35 
     36[[BR]] 
     37 
     38== Setting Up Eclipse == 
     39 
     40 1. Run Eclipse 
     41 1. Configure workspace: 
     42      - Create/select a directory for your workspace the first time you run Eclipse. This directory should be placed outside your PJPROJECT directory. 
     43 1. Disable auto-build everytime something changes: 
     44      - Uncheck '''Project''' --> '''Build Automatically''' 
     45 1. Set proper indentation for PJSIP: 
     46      - Select menu: 
     47        - Linux: '''Window''' --> '''Preferences''' 
     48        - Mac: '''Eclipse''' --> '''Preferences''' 
     49      - In the '''Preferences''' dialog, from the tree, select '''C/C++''' --> '''Code Style''' 
     50      - in the code style, press '''New''': 
     51           - Profile name: '''pjsip''' 
     52           - Initialize settings with the following profile: '''K&R [built-in]''' 
     53           - Click OK 
     54      - in the '''pjsip''' profile editing dialog: 
     55           - Tab policy: '''mixed''' 
     56           - Uncheck '''Use tabs only''' 
     57           - Indentation: '''4''' 
     58           - Tab size: '''8''' 
     59           - Click OK to close '''pjsip''' profile editing dialog 
     60      - Click OK to close '''Preferences''' dialog. 
     61 1. To activate Visual Studio style key shortcuts: 
     62      - Select menu: 
     63        - Linux: '''Window''' --> '''Preferences''' 
     64        - Mac: '''Eclipse''' --> '''Preferences''' 
     65      - In the '''Preferences''' dialog, from the tree, select '''General''' --> '''Keys''' 
     66      - Select '''Microsoft Visual Studio''' scheme 
     67      - Customize other key shortcuts as wanted (for example, F7 for Build) 
     68 1. Disable menubar F10 acceleration key: 
     69    - Ubuntu/Gnome: 
     70      - 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) 
     71      - To disable F10 from popping up the application menu, open terminal and run: 
     72        {{{ 
     73$ gconftool-2 -s --type string /desktop/gnome/interface/menubar_accel 'F12' 
     74        }}} 
     75        Basically the command above assigns menubar acceleration key to something other than F10, in this case F12 key 
     76    - Mac: 
     77      - System Preference --> Keyboard & Mouse --> Keyboard shortcuts 
     78      - Uncheck F10 
     79 
     80 
     81[[BR]] 
     82 
     83== Importing PJSIP == 
     84 
     85To import PJSIP into your Eclipse workspace: 
     86 
     87 1. Create a new project for PJPROJECT: 
     88    1. Select '''File''' --> '''New''' --> '''C Project''' menu. 
     89    1. In the ''C Project'' dialog: 
     90       - Project name: '''pjproject''' 
     91       - Uncheck ''Use default location'' checkbox 
     92       - Location: set to the location of you PJPROJECT installation 
     93       - Project type: '''Makefile project''' --> '''Empty Project''' 
     94       - Toolchains: '''Linux GCC''' 
     95    1. Click '''Finish''' 
     96 1. You should now see your project in the ''Project Explorer'' pane. 
     97 
     98[[BR]] 
     99 
     100== Customizing PJSIP == 
     101 
     102 1. Compile time customizations can be put in '''user.mak''' file in your root PJPROJECT directory. Example of a user.mak file content: 
     103    {{{ 
     104    export CFLAGS += -g 
     105    export LDFLAGS += 
     106    }}} 
     107 1. Other customizations can be put in '''config_site.h''' as usual. 
     108 
     109[[BR]] 
     110 
     111== Debugging the Project == 
     112 
     113 1. Don't forget to put '''-g''' flag in your '''user.mak''' and possibly remove any optimization flags. 
     114 1. Don't forget to run '''make dep''' once, otherwise dependencies wouldn't have been set correctly. 
     115 1. Build the project 
     116 1. Create a new Debug configuration for each executable that you want to debug: 
     117    1. Open '''Run''' --> '''Debug Configurations''' 
     118    1. Select '''C/C++ Application''' from the left tree pane, and press '''New''' button 
     119    1. Edit the Debug Configuration: 
     120       1. Name: '''pjsua''' (for example) 
     121       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) 
     122       1. Go to Debugger tab: 
     123          - if Debugger is not set, select '''gdb/mi''' 
     124          - uncheck '''Stop on startup at..''' 
     125       1. Click Apply 
     126    1. Click '''Debug''' to start debugging 
     127 1. You may set breakpoints, inspect variables, step into/over, etc. as you would expect from a decent IDE. 
     128 
     129[[BR]] 
     130 
     131== Problems and Solutions == 
     132 
     133=== I have not been able to set breakpoints === 
     134 
     135Make sure the project is built with debugging flag (i.e. "-g") 
     136 
     137=== When I step into/over the code, the execution moves erraticly === 
     138 
     139Make sure optimization flag is turned off. 
     140 
     141 
     142 
     143{{{ 
     144#!html 
     145<!-- MAIN TABLE END --> 
     146</td></tr></table> 
     147}}} 
     148