Skip to main content

Thread: Problem linking with curl since Pangolin (12.04)


hello,

have problem linking programs using curl since 12.04

example, example givent curl development documentations: cookie_interface.c below

code:
/*****************************************************************************   *                                  _   _ ____  _   *  project                     ___| | | |  _ \| |   *                             / __| | | | |_) | |   *                            | (__| |_| |  _ <| |___   *                             \___|\___/|_| \_\_____|   *   *  example shows usage of simple cookie interface.    */    #include <stdio.h>  #include <string.h>  #include <stdlib.h>  #include <errno.h>  #include <time.h>    #include <curl/curl.h>    static void  print_cookies(curl *curl)  {    curlcode res;    struct curl_slist *cookies;    struct curl_slist *nc;    int i;      printf("cookies, curl knows:\n");    res = curl_easy_getinfo(curl, curlinfo_cookielist, &cookies);    if (res != curle_ok) {      fprintf(stderr, "curl curl_easy_getinfo failed: %s\n", curl_easy_strerror(res));      exit(1);    }    nc = cookies, = 1;    while (nc) {      printf("[%d]: %s\n", i, nc->data);      nc = nc->next;      i++;    }    if (i == 1) {      printf("(none)\n");    }    curl_slist_free_all(cookies);  }    int  main(void)  {    curl *curl;    curlcode res;      curl_global_init(curl_global_all);    curl = curl_easy_init();    if (curl) {      char nline[256];        curl_easy_setopt(curl, curlopt_url, "http://www.google.com/"); /* google.com sets "pref" cookie */      curl_easy_setopt(curl, curlopt_verbose, 1l);      curl_easy_setopt(curl, curlopt_cookiefile, ""); /* start cookie engine */      res = curl_easy_perform(curl);      if (res != curle_ok) {        fprintf(stderr, "curl perform failed: %s\n", curl_easy_strerror(res));        return 1;      }        print_cookies(curl);        printf("erasing curl's knowledge of cookies!\n");      curl_easy_setopt(curl, curlopt_cookielist, "all");        print_cookies(curl);        printf("-----------------------------------------------\n"             "setting cookie \"pref\" via cookie interface:\n");  #ifdef win32  #define snprintf _snprintf  #endif      /* netscape format cookie */      snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%lu\t%s\t%s",        ".google.com", "true", "/", "false", time(null) + 31337, "pref", "hello google, much!");      res = curl_easy_setopt(curl, curlopt_cookielist, nline);      if (res != curle_ok) {        fprintf(stderr, "curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));        return 1;                  }        /* http-header style cookie */      snprintf(nline, sizeof(nline),        "set-cookie: old_pref=3d141414bf4209321; "        "expires=sun, 17-jan-2038 19:14:07 gmt; path=/; domain=.google.com");      res = curl_easy_setopt(curl, curlopt_cookielist, nline);      if (res != curle_ok) {        fprintf(stderr, "curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));        return 1;                  }        print_cookies(curl);        res = curl_easy_perform(curl);      if (res != curle_ok) {        fprintf(stderr, "curl perform failed: %s\n", curl_easy_strerror(res));        return 1;      }    }    else {      fprintf(stderr, "curl init failed!\n");      return 1;    }      curl_global_cleanup();    return 0;  }
normally, compiled/linked 1 command line, , working on 10.04, way:
code:
`curl-config --cc --cflags --libs`  -o cookie_interface cookie_interface.c
of course, have installed libcurl stuff with:
code:
sudo apt-get install libcurl4-gnutls-dev
and since 12.04, get:
code:
$ `curl-config --cc --cflags --libs`  -o cookie_interface cookie_interface.c   /tmp/ccyjd6nn.o: in function `print_cookies':  cookie_interface.c:(.text+0xc3): undefined reference `curl_easy_getinfo'  cookie_interface.c:(.text+0xd6): undefined reference `curl_easy_strerror'  cookie_interface.c:(.text+0x161): undefined reference `curl_slist_free_all'  /tmp/ccyjd6nn.o: in function `main':  cookie_interface.c:(.text+0x187): undefined reference `curl_global_init'  cookie_interface.c:(.text+0x18c): undefined reference `curl_easy_init'  cookie_interface.c:(.text+0x1cc): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x1f7): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x222): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x231): undefined reference `curl_easy_perform'  cookie_interface.c:(.text+0x24d): undefined reference `curl_easy_strerror'  cookie_interface.c:(.text+0x2ba): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x35f): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x37b): undefined reference `curl_easy_strerror'  cookie_interface.c:(.text+0x3ef): undefined reference `curl_easy_setopt'  cookie_interface.c:(.text+0x40b): undefined reference `curl_easy_strerror'  cookie_interface.c:(.text+0x452): undefined reference `curl_easy_perform'  cookie_interface.c:(.text+0x46e): undefined reference `curl_easy_strerror'  cookie_interface.c:(.text+0x4c4): undefined reference `curl_global_cleanup'  collect2: ld retourné 1 code d'état d'exécution
so, see compilation ok, linker (ld) not find of symbols belonging libcurl.

suspect error due new multiarch organisation, other things done wrong.


idea on how solve (link programs curl correctly)?

answered here https://bugs.launchpad.net/bugs/1001576
use
code:
`curl-config --cc --cflags`  -o cookie_interface cookie_interface.c `curl-config --libs`


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Ubuntu Dev Link Forum [SOLVED] Problem linking with curl since Pangolin (12.04)


Ubuntu

Comments

Popular posts from this blog

Thread: gpg: Conflicting Commands

Adobe Acrobat Pro , Terminal Server Use

when i try using AE CC 3d camera tracker after the first step it says "Analysis solve failed." help?