title: Code::Blocks output "error: ld returned 1 exit status" without else
body: <p>My Code::Blocks IDE is calling just "error: ld returned 1 exit status" when I build my code. I frequently saw this error with "collect2:" as "collect2: ld returned 1 exit status". I just know this is linker error. So I need to include another linraries.</p>
  
  <p>But I'm  inexperienced to use this IDE even if C++.</p>
  
  <p>So I don't get it how I get rid of this error.</p>
  
  <p>I would like to ask below things.</p>
  
  <p>1)How to get rid of this error. What issues are considered.</p>
  
  <p>2)How to set up Build options to suit my code in below.</p>
  
  <p><strong>Note(Build opetions)</strong>:
  Link libraries in Linker setting is added</p>
  
  <pre><code>../../opencv-2.4.13/build/lib/libopencv_highgui.so
  
  ../../opencv-2.4.13/build/lib/libopencv_core.so
  
  ../../opencv-2.4.13/build/lib/libopencv_imgproc.so
  
  pthread
  
  boost_system
  </code></pre>
  
  <p>and, Compiler in Search directories is</p>
  
  <pre><code>../../opencv-2.4.13/include/opencv
  
  ../../../../usr/include/boost
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TCZSJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCZSJ.png" alt="MyDesktop"></a></p>
  
  <pre><code>#include &lt;cv.h&gt;
  #include &lt;cxcore.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;boost/interprocess/managed_shared_memory.hpp&gt;
  #include &lt;boost/interprocess/managed_mapped_file.hpp&gt; 
  #include &lt;boost/interprocess/containers/vector.hpp&gt;   // boost/containers/vector.hpp
  #include &lt;boost/interprocess/containers/string.hpp&gt;   // boost/containers/string.hpp
  #include &lt;iostream&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;stdio.h&gt;
  
   //                                                                    void_allocator;
  namespace bip = boost::interprocess;
  
  typedef unsigned char uchar;
  //Typedefs of allocators and containers
  typedef bip::managed_shared_memory::segment_manager                       segment_manager_t;
  typedef bip::allocator&lt;void, segment_manager_t&gt;  void_allocator;
  
  typedef void_allocator::rebind&lt;uchar&gt;::other                           uchar_allocator;
  typedef bip::vector&lt;uchar, uchar_allocator&gt;                                   uchar_vector;
  
  
  
  template &lt;typename Alloc = std::allocator&lt;uchar&gt; &gt;
  struct BasicInData {
  
      public:
          BasicInData(Alloc alloc = {}) : image(alloc)
          { }
  
          template &lt;typename T&gt;
          BasicInData(double x, int sizeImg, uchar_vector&amp; image, Alloc alloc = {}) :
              x(x), sizeImg(sizeImg), image(alloc)
          { }
  
          double x = 0;
          int sizeImg = 0;
          uchar_vector image;
  };
  
  using InData = BasicInData&lt;&gt;; // just heap allocated
  
  namespace Shared {
      using segment                      = bip::managed_shared_memory;
      using segment_manager              = segment::segment_manager;
  
      template &lt;typename T&gt; using alloc  = bip::allocator&lt;T, segment_manager&gt;;
      template &lt;typename T&gt; using vector = bip::vector&lt;T, alloc&lt;T&gt; &gt;;
  
      using InData = BasicInData&lt;alloc&lt;uchar&gt; &gt;; // shared memory version
  
      vector&lt;InData&gt;&amp; locate(segment&amp; smt) {
          auto* v = smt.find_or_construct&lt;vector&lt;InData&gt; &gt;("InDataVector")(smt.get_segment_manager());
          assert(v);
          return *v;
      }
  }
  
  
  int main(int argc, char* argv[]) {
      if(argc == 1){ //Parent process
          // Remove shared memory on construction and destruction
  
          // Create a new segment with given name and size
          struct timeval tv;
          gettimeofday(&amp;tv, NULL);
          struct shm_remove
          {
              shm_remove(){bip::shared_memory_object::remove("MySharedMemory");}
              ~shm_remove(){bip::shared_memory_object::remove("MySharedMemory");}
          }remover;
          Shared::segment smt(bip::create_only,"MySharedMemory", 65536); // 10 Kb for coliru
          auto &amp;data = Shared::locate(smt);
          //Shared::alloc bip::alloc_inst (data);
  
          cv::Mat_&lt;cv::Vec3b&gt; mat;
          cv::VideoCapture vcap(0);
  
          Shared::InData id(smt.get_segment_manager());
  
  
          if (!vcap.isOpened())
              return -1;
  
          while (1) {
              vcap &gt;&gt; mat;
              int image_size = mat.total() * mat.elemSize();
              id.sizeImg = image_size;
              id.image.resize(image_size * sizeof(uchar));
              memcpy(&amp;id.image[0], mat.data, image_size * sizeof(uchar));
              //Launch child process
              gettimeofday(&amp;tv, NULL);
              double time = ((double)tv.tv_usec/1000000);
              id.x = time;
              data.push_back(id);
              if(cv::waitKey(30) &gt;= 0) break;
          }
  
          std::string s(argv[0]); s += " child";
          if(0 != std::system(s.c_str()))
              return 1;
  
          // check child has destroyed the vector
          if(smt.find&lt;Shared::vector&lt;InData&gt;&gt;("InDataVector").first)
              return 1;
  
      } else{
          // Open the managed segment
          bip::managed_shared_memory segment(bip::open_only, "MySharedMemory");
  
          // Find the vector using c-string name
          bip::vector&lt;InData&gt; *myvector = segment.find&lt;bip::vector&lt;InData&gt;&gt;("InDataVector").first;
          // Use vector in reverse order
  
          bip::vector&lt;InData&gt;::iterator it;
  
          cv::Mat_&lt;cv::Vec3b&gt; im;
          for(it = myvector-&gt;begin(); it !=myvector-&gt;end(); ++it){
              im.resize(it-&gt;sizeImg);
              memcpy(im.data, &amp;it-&gt;image[0], it-&gt;sizeImg);
              cv::imshow("window1", im);
          }
  
          segment.destroy&lt;bip::vector&lt;InData&gt;&gt;("InDataVector");
  
          return 0;
      }
  }
  </code></pre>