title: C++ command line arguments Eclipse CDT?
body: <p>I am using an example program from this code <a href="http://sicktoolbox.sourceforge.net/" rel="noreferrer">http://sicktoolbox.sourceforge.net/</a> > <a href="http://sourceforge.net/projects/sicktoolbox/files/" rel="noreferrer">http://sourceforge.net/projects/sicktoolbox/files/</a> . It's basically a distance scanner driver. The program I'm trying to run is in sicktoolbox-1.0.1/c++/examples/lms/lms_plot_values in case you wanted to see the code I'm talking about.</p>
  
  <p>Anyways, the lms_plot_values project folder contains gnuplot_i.cc, gnuplot_i.hpp, main.cc, Makefile, Makefile.am, Makefile.in. So I put the first three files in my Eclipse Indigo CDT, compile (no compiler errors, everything's correctly linked in Eclipse already and all needed libraries are added), but this sample program is written to take in command line arguments. Here is as far as the code gets. </p>
  
  <pre><code>/*!
   * \file main.cc
   * \brief Illustrates how to acquire a measurements from the Sick
   *        LMS 2xx using the configured measuring mode.
   *
   * Note: This example should work for all Sick LMS 2xx models.
   *
   * Code by Jason C. Derenick and Thomas H. Miller.
   * Contact derenick(at)lehigh(dot)edu
   *
   * The Sick LIDAR Matlab/C++ Toolbox
   * Copyright (c) 2008, Jason C. Derenick and Thomas H. Miller
   * All rights reserved.
   *
   * This software is released under a BSD Open-Source License.
   * See http://sicktoolbox.sourceforge.net
   */
  
  /* Implementation dependencies */
  #include &lt;stdlib.h&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;signal.h&gt;
  #include &lt;iostream&gt;
  #include &lt;sicklms-1.0/SickLMS.hh&gt;
  #include "gnuplot_i.hpp"
  
  using namespace std;
  using namespace SickToolbox;
  
  bool running = true;
  void sigintHandler(int signal);
  
  int main(int argc, char * argv[]) {
  
    string device_str; // Device path of the Sick LMS 2xx
    SickLMS::sick_lms_baud_t desired_baud = SickLMS::SICK_BAUD_38400;
  
    /* Check for a device path.  If it's not present, print a usage statement. */
    if ((argc != 2 &amp;&amp; argc != 3) || (argc == 2 &amp;&amp; strcasecmp(argv[1],"--help") == 0)) {
      cout &lt;&lt; "Usage: lms_plot_values PATH [BAUD RATE]" &lt;&lt; endl
       &lt;&lt; "Ex: lms_plot_values /dev/ttyUSB0 9600" &lt;&lt; endl;
      return -1;
    }
  </code></pre>
  
  <p>As it says, it throws an error and kills the program, saying it wants me to type "lms_plot_values /dev/ttyUSB0 9600" from the command line to run the program, but I can't do that, and I'm wanting to do everything in eclipse so I don't want to do that. I tried adding:</p>
  
  <pre><code>argv[1] = "/dev/ttyUSB0";
  argv[2] = "9600";
  </code></pre>
  
  <p>But that didn't work because of the argc checks. Do you know if it says to pass in "lms_plot_values /dev/ttyUSB0 9600", why it would be expecting or where it would be getting the argc values from? Or how I can make it think these parameters were passed in? I'm not very familiar with how C++ works like this, I've only used Java.</p>
  
  <p>Thanks for any help</p>