cURL / Mailing Lists / curl-library / Single Mail


libcurl error question

From: <>
Date: Sun, 29 Jun 2014 10:09:39 -0400 (EDT)

I have been trying to get the libcurl library to work with the
following program shown below but I have been getting the following

 ||=== Build: Debug in test3 (compiler: GNU GCC Compiler) ===|
 obj\Debug\main.o||In function `Z8getstockPcS_':|
 undefined reference to `_imp__curl_global_init'|
 undefined reference to `_imp__curl_easy_init'|
 undefined reference to `_imp__curl_easy_setopt'|
 undefined reference to `_imp__curl_easy_setopt'|
 undefined reference to `_imp__curl_easy_setopt'|
 undefined reference to `_imp__curl_easy_setopt'|
 undefined reference to `_imp__curl_easy_setopt'|
 undefined reference to `_imp__curl_easy_perform'|
 undefined reference to `_imp__curl_easy_cleanup'|
 undefined reference to `_imp__curl_global_cleanup'|
  ||=== Build failed: 10 error(s), 0 warning(s) (0 minute(s), 0
second(s)) ===|

  I'm confused as to why this is occurring. I'm using Windows 7 64bit
and Code::Blocks. Under 'build options' 'linker settings' and 'link
libraries' I added all the libraries listed in the lib64 folder namely,
libcrypto.a, libcrypto.dll.a, libcurl.a, libcurldll.a, librtmp.a,
libssh2.a, libssh2dll.a, libssl.a, libssl.dll.a, libz.a, libz.dll.a,
and libzdll.a. Under 'search directories' 'compiler' I included
c:\lib\curl-7.34.0-devel-mingw64\include and under 'search directories'
'linker' I included c:\lib\curl-7.34.0-devel-mingw64\lib64. As far as I
can tell I'm doing everything right. So why isn't this working? Program
shown below.

 #include <stdio.h>
#include <curl/curl.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <ctime>
#include <iterator>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <random>
#include <chrono>

using namespace std;

struct FtpFile {
  const char *filename;
  FILE *stream;

static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void
  struct FtpFile *out=(struct FtpFile *)stream;
  if(out && !out->stream) {
    /* open file for writing */
    out->stream=fopen(out->filename, "wb");
      return -1; /* failure, can't open file to write */
  return fwrite(buffer, size, nmemb, out->stream);

void get(char *url3, char *url4);

int main()
  return 0;

void get(char *url3, char *url4)
  CURL *curl;
  CURLcode res;
  struct FtpFile ftpfile={
    url4, /* name to store the file as if succesful */


  curl = curl_easy_init();

  if(curl) {
     * You better replace the URL with one that works!
     curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(curl, CURLOPT_URL,
     /* Define our callback to get called when there's data to be
written */
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
    /* Set a pointer to our struct to pass to the callback */
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);

    /* Switch on full protocol/debug output */
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

    res = curl_easy_perform(curl);

    /* always cleanup */

    if(CURLE_OK != res) {
      /* we failed */
      fprintf(stderr, "curl told us %d\n", res);

    fclose(; /* close the local file */


List admin:
Received on 2014-06-29