title: Kurento: Link library in OpenCV module
body: <p>I'm writing an OpenCV module to go with Kurento Media Server.
  I'm reading a file from an URL using lib curl.</p>
  
  <p>The code I have is as follows:</p>
  
  <pre><code>#include&lt;curl/curl.h&gt;
  
  size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata)
  {
      vector&lt;uchar&gt; *stream = (vector&lt;uchar&gt;*)userdata;
      size_t count = size * nmemb;
      stream-&gt;insert(stream-&gt;end(), ptr, ptr + count);
      return count;
  }
  
  Mat curlImg(const char *img_url, int timeout=10)
  {
      vector&lt;uchar&gt; stream;
      CURL *curl = curl_easy_init();
      curl_easy_setopt(curl, CURLOPT_URL, img_url);
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); 
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &amp;stream);
      curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
      curl_easy_perform(curl);
      curl_easy_cleanup(curl);
      return imdecode(stream, -1);
  }
  
  Mat image = curlImg(link);
  </code></pre>
  
  <p>Upon building it: I get the following warnings and the resultant package is not installed:</p>
  
  <p>dpkg-shlibdeps: warning: symbol curl_easy_cleanup found in none of the libraries <br/>
  dpkg-shlibdeps: warning: symbol curl_easy_perform found in none of the libraries<br/>
  dpkg-shlibdeps: warning: symbol curl_easy_setopt found in none of the libraries<br/>
  dpkg-shlibdeps: warning: symbol curl_easy_init found in none of the libraries<br/></p>
  
  <p>My guess is that there is a problem with linking the libraries in CMakeLists.txt
  <br/><br/>
  So how should I link these libraries?<br/>
  Is target_link_libraries() the correct way? If so, what is the syntax?</p>
  
  <p><br/><br/>
  <strong>Edit:</strong></p>
  
  <p>These are the ways I've tried so far.</p>
  
  <p><strong>1</strong><br/></p>
  
  <pre><code>SET(requiredlibs)
  
  FIND_PACKAGE(CURL)
  IF(CURL_FOUND)
      INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
      SET(requiredlibs ${requiredlibs} ${CURL_LIBRARIES} )
  ELSE(CURL_FOUND)
      MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.")
  ENDIF(CURL_FOUND)
  </code></pre>
  
  <p><strong>2</strong><br/></p>
  
  <pre><code>target_link_libraries (curl)
  </code></pre>
  
  <p><strong>3</strong><br/></p>
  
  <pre><code>SET(${CURL_LIBRARIES} )
  </code></pre>