undefined reference

Discussion in 'C Programming' started by gert, Feb 9, 2007.

  1. gert

    gert Guest

    Does anyone develop fcgi aplicatioins ?

    gert@gert:~/Desktop/svn/Cgi$ gcc -o bin obj.c
    /tmp/ccTRfdlo.o: In function `main':
    obj.c:(.text+0x99): undefined reference to `FCGI_printf'
    obj.c:(.text+0x9e): undefined reference to `FCGI_Accept'
    collect2: ld returned 1 exit status
    gert@gert:~/Desktop/svn/Cgi$
     
    gert, Feb 9, 2007
    #1
    1. Advertising

  2. gert

    gert Guest

    On Feb 10, 12:13 am, "gert" <> wrote:
    > Does anyone develop fcgi aplicatioins ?
    >
    > gert@gert:~/Desktop/svn/Cgi$ gcc -o bin obj.c
    > /tmp/ccTRfdlo.o: In function `main':
    > obj.c:(.text+0x99): undefined reference to `FCGI_printf'
    > obj.c:(.text+0x9e): undefined reference to `FCGI_Accept'
    > collect2: ld returned 1 exit status
    > gert@gert:~/Desktop/svn/Cgi$


    forgot to add the source code :)

    #include <fcgi_stdio.h>
    #include <stdlib.h>

    typedef struct self{
    int value;
    int (*add)(struct self*,int);
    } obj;

    int add(obj* this, int val) {
    this->value = val;
    return this->value;
    }

    obj* Obj(void){
    obj* new = malloc(sizeof *new);
    new->value = 0;
    new->add = add;
    return new;
    }

    int main (int argc, char** argv){
    obj* myobj=Obj();
    myobj->add(myobj,7);
    while (FCGI_Accept() >= 0) {
    printf("Content-type: text/html\r\n"
    "\r\n"
    "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
    "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
    "Request number %d running on host <i>%s</i>\n",
    myobj->value, getenv("SERVER_HOSTNAME"));
    }
    return 0;
    }
     
    gert, Feb 9, 2007
    #2
    1. Advertising

  3. gert

    Guest

    On Feb 9, 11:22 pm, "gert" <> wrote:
    > On Feb 10, 12:13 am, "gert" <> wrote:
    >
    > > Does anyone develop fcgi aplicatioins ?

    >
    > > gert@gert:~/Desktop/svn/Cgi$ gcc -o bin obj.c
    > > /tmp/ccTRfdlo.o: In function `main':
    > > obj.c:(.text+0x99): undefined reference to `FCGI_printf'
    > > obj.c:(.text+0x9e): undefined reference to `FCGI_Accept'
    > > collect2: ld returned 1 exit status
    > > gert@gert:~/Desktop/svn/Cgi$

    >
    > forgot to add the source code :)
    >
    > #include <fcgi_stdio.h>
    > #include <stdlib.h>
    >
    > typedef struct self{
    > int value;
    > int (*add)(struct self*,int);
    >
    > } obj;
    >
    > int add(obj* this, int val) {
    > this->value = val;
    > return this->value;
    >
    > }
    >
    > obj* Obj(void){
    > obj* new = malloc(sizeof *new);
    > new->value = 0;
    > new->add = add;
    > return new;
    >
    > }
    >
    > int main (int argc, char** argv){
    > obj* myobj=Obj();
    > myobj->add(myobj,7);
    > while (FCGI_Accept() >= 0) {
    > printf("Content-type: text/html\r\n"
    > "\r\n"
    > "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
    > "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
    > "Request number %d running on host <i>%s</i>\n",
    > myobj->value, getenv("SERVER_HOSTNAME"));
    > }
    > return 0;
    >
    > }


    OT, but add -L/path/containing/libfcgi.so -lfcgi.

    MC
     
    , Feb 9, 2007
    #3
  4. On 9 Feb 2007 15:13:14 -0800, in comp.lang.c , "gert"
    <> wrote:

    >Does anyone develop fcgi aplicatioins ?
    >
    >gert@gert:~/Desktop/svn/Cgi$ gcc -o bin obj.c
    >/tmp/ccTRfdlo.o: In function `main':
    >obj.c:(.text+0x99): undefined reference to `FCGI_printf'
    >obj.c:(.text+0x9e): undefined reference to `FCGI_Accept'
    >collect2: ld returned 1 exit status
    >gert@gert:~/Desktop/svn/Cgi$


    Even without the source code, this is detectable as FAQ 10.10b.

    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Feb 10, 2007
    #4
  5. gert

    gert Guest

    On Feb 10, 7:56 pm, Mark McIntyre <> wrote:
    > Even without the source code, this is detectable as FAQ 10.10b.
    >


    Where can i find the faq ?
     
    gert, Feb 11, 2007
    #5
  6. gert

    gert Guest

    On Feb 11, 1:42 am, "gert" <> wrote:
    > On Feb 10, 7:56 pm, Mark McIntyre <> wrote:
    >
    > > Even without the source code, this is detectable as FAQ 10.10b.

    >
    > Where can i find the faq ?


    Never mind i found the faq but i still dont understand how to fix the
    problem ?
     
    gert, Feb 11, 2007
    #6
  7. Christopher Layne, Feb 11, 2007
    #7
  8. On 10 Feb 2007 16:52:46 -0800, in comp.lang.c , "gert"
    <> wrote:

    >On Feb 11, 1:42 am, "gert" <> wrote:
    >> On Feb 10, 7:56 pm, Mark McIntyre <> wrote:
    >>
    >> > Even without the source code, this is detectable as FAQ 10.10b.

    >>
    >> Where can i find the faq ?

    >
    >Never mind i found the faq but i still dont understand how to fix the
    >problem ?
    >


    If you read the FAQ, it explains what the problem is - you need to
    link against the right libraries. How you do this is system-specific
    and you need to RTFM for your toolset, and/or ask in a specialist
    group. Hint: find out what the -l ( minus ell) flag does.
    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Feb 11, 2007
    #8
  9. gert

    gert Guest

    Alelooia

    gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    Desktop/svn/db/cgi/header.c

    And No i have no idea why it compiles or what the difference is
    between the big -L and the small -l :)

    I am just a little frustrated trying the hole weekend to display hello
    world om my browser

    If only my lighttpd webserver would now be nice enough to finaly run
    my cgi i would be happy.
     
    gert, Feb 11, 2007
    #9
  10. gert

    gert Guest

    On Feb 11, 7:18 pm, "gert" <> wrote:
    > Alelooia
    >
    > gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    > Desktop/svn/db/cgi/header.c
    >
    > And No i have no idea why it compiles or what the difference is
    > between the big -L and the small -l :)
    >
    > I am just a little frustrated trying the hole weekend to display hello
    > world om my browser
    >
    > If only my lighttpd webserver would now be nice enough to finaly run
    > my cgi i would be happy.


    WHAAAAAAAAAAAAA going postal

    /home/gert/Desktop/svn/db/cgi/header.cgi: error while loading shared
    libraries: libfcgi.so.0: cannot open shared object file: No such file
    or directory
     
    gert, Feb 11, 2007
    #10
  11. gert

    gert Guest

    On Feb 11, 7:29 pm, "gert" <> wrote:
    > On Feb 11, 7:18 pm, "gert" <> wrote:
    >
    > > Alelooia

    >
    > > gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    > > Desktop/svn/db/cgi/header.c

    >
    > > And No i have no idea why it compiles or what the difference is
    > > between the big -L and the small -l :)

    >
    > > I am just a little frustrated trying the hole weekend to display hello
    > > world om my browser

    >
    > > If only my lighttpd webserver would now be nice enough to finaly run
    > > my cgi i would be happy.

    >
    > WHAAAAAAAAAAAAA going postal
    >
    > /home/gert/Desktop/svn/db/cgi/header.cgi: error while loading shared
    > libraries: libfcgi.so.0: cannot open shared object file: No such file
    > or directory


    gert@gert:/usr/local/lib$ ls
    libfcgi.a libfcgi.la libfcgi.so libfcgi.so.0 libfcgi.so.
    0.0.0 python2.4 site_ruby
    libfcgi++.a libfcgi++.la libfcgi++.so libfcgi++.so.0 libfcgi++.so.
    0.0.0 python2.5

    gert@gert:~$ gcc -L/usr/local/lib/ -lfcgi -o Desktop/svn/db/cgi/
    header.cgi Desktop/svn/db/cgi/header.c

    gert@gert:~$ ./Desktop/svn/db/cgi/header.cgi
    ../Desktop/svn/db/cgi/header.cgi: error while loading shared libraries:
    libfcgi.so.0: cannot open shared object file: No such file or
    directory

    gert@gert:~$ gcc -L/usr/local/lib/libfcgi.so -lfcgi -o Desktop/svn/db/
    cgi/header.cgi Desktop/svn/db/cgi/header.c

    gert@gert:~$ ./Desktop/svn/db/cgi/header.cgi
    ../Desktop/svn/db/cgi/header.cgi: error while loading shared libraries:
    libfcgi.so.0: cannot open shared object file: No such file or
    directory

    gert@gert:~$ gcc -l/usr/local/lib/libfcgi.so -o Desktop/svn/db/cgi/
    header.cgi Desktop/svn/db/cgi/header.c
    /usr/bin/ld: cannot find -l/usr/local/lib/libfcgi.so
    collect2: ld returned 1 exit status

    gert@gert:~$ gcc -l/usr/local/lib/libfcgi.so.0 -o Desktop/svn/db/cgi/
    header.cgi Desktop/svn/db/cgi/header.c
    /usr/bin/ld: cannot find -l/usr/local/lib/libfcgi.so.0
    collect2: ld returned 1 exit status

    gert@gert:~$ gcc -L/usr/local/lib/libfcgi.so -lfcgi -o Desktop/svn/db/
    cgi/header.cgi Desktop/svn/db/cgi/header.c

    gert@gert:~$ ./Desktop/svn/db/cgi/header.cgi
    ../Desktop/svn/db/cgi/header.cgi: error while loading shared libraries:
    libfcgi.so.0: cannot open shared object file: No such file or
    directory

    gert@gert:~$
     
    gert, Feb 11, 2007
    #11
  12. gert

    gert Guest

    On Feb 11, 7:29 pm, "gert" <> wrote:
    > On Feb 11, 7:18 pm, "gert" <> wrote:
    >
    > > Alelooia

    >
    > > gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    > > Desktop/svn/db/cgi/header.c

    >
    > > And No i have no idea why it compiles or what the difference is
    > > between the big -L and the small -l :)

    >
    > > I am just a little frustrated trying the hole weekend to display hello
    > > world om my browser

    >
    > > If only my lighttpd webserver would now be nice enough to finaly run
    > > my cgi i would be happy.

    >
    > WHAAAAAAAAAAAAA going postal
    >
    > /home/gert/Desktop/svn/db/cgi/header.cgi: error while loading shared
    > libraries: libfcgi.so.0: cannot open shared object file: No such file
    > or directory


    added /usr/local/lib to ldconfig

    gert@gert:~$ Desktop/compile.sh
    Content-Type: text/xml; charset=utf-8

    <xml>server,text,localhost,user,text,root,password,text,</xml>
    gert@gert:~$

    so here i am with this .cgi file and a webserver

    fastcgi.server = ( ".php" =>
    ( "localhost" =>
    (
    "bin-path" => "/usr/lib/cgi-bin/
    php" ,
    "socket" => "/tmp/php-
    fcgi.socket"
    )
    ),
    ".cgi" =>
    ( "localhost" =>
    (
    "bin-path" => "/home/gert/Desktop/
    svn/db/cgi/header.cgi" ,
    "socket" => "/tmp/c-
    fcgi.socket"
    )
    )
    )

    and i now realize this is NOT what i want, beacuse it only excecutes
    one .cgi file and i have many .cgi files ??????
     
    gert, Feb 11, 2007
    #12
  13. On 11 Feb 2007 10:18:38 -0800, in comp.lang.c , "gert"
    <> wrote:

    >And No i have no idea why it compiles or what the difference is
    >between the big -L and the small -l :)


    Then read the manual....

    >I am just a little frustrated trying the hole weekend to display hello
    >world om my browser


    Programming is like that sometimes. This is especially the case if you
    start with the wrong paradigm and attempt to force a programming
    language to do stuff its not designed for.

    >If only my lighttpd webserver would now be nice enough to finaly run
    >my cgi i would be happy.


    Personally I'd abandon C - try php or perl. It took me about 2
    minutes to write a hello world proggy in the latter.

    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Feb 11, 2007
    #13
  14. On 11 Feb 2007 10:47:26 -0800, in comp.lang.c , "gert"
    <> wrote:

    >> WHAAAAAAAAAAAAA going postal
    >>

    >gert@gert:/usr/local/lib$ ls
    >libfcgi.a libfcgi.la libfcgi.so libfcgi.so.0 libfcgi.so.
    >0.0.0 python2.4 site_ruby
    >libfcgi++.a libfcgi++.la libfcgi++.so libfcgi++.so.0 libfcgi++.so.
    >0.0.0 python2.5
    >
    >gert@gert:~$ gcc -L/usr/local/lib/ -lfcgi -o Desktop/svn/db/cgi/
    >header.cgi Desktop/svn/db/cgi/header.c
    >
    >gert@gert:~$ ./Desktop/svn/db/cgi/header.cgi
    >./Desktop/svn/db/cgi/header.cgi: error while loading shared libraries:
    >libfcgi.so.0: cannot open shared object file: No such file or
    >directory


    Whatever your problem is, its nothing to do with C. You really really
    need to learn how to use your toolset. You could try asking in a gcc
    newsgroup....
    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Feb 11, 2007
    #14
  15. On 11 Feb 2007 11:54:19 -0800, in comp.lang.c , "gert"
    <> wrote:

    >added /usr/local/lib to ldconfig


    (stufff)

    >and i now realize this is NOT what i want, beacuse it only excecutes
    >one .cgi file and i have many .cgi files ??????


    And now you're talking about how to configure your webserver, it
    seems. This is NOT topical here....

    Gert, please understand that nobody is being unhelpful. Its just that
    you're asking in the wrong place. You don't ask garage mechanics about
    the price of wheat. You don't ask farmers about how to rebore a
    straight 12 diesel.
    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Feb 11, 2007
    #15
  16. gert

    CBFalconer Guest

    gert wrote:
    >
    > gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    > Desktop/svn/db/cgi/header.c
    >
    > And No i have no idea why it compiles or what the difference is
    > between the big -L and the small -l :)
    >
    > I am just a little frustrated trying the hole weekend to display
    > hello world om my browser
    >
    > If only my lighttpd webserver would now be nice enough to finaly
    > run my cgi i would be happy.


    See my sig below. As it is, your article is meaningless.

    --
    If you want to post a followup via groups.google.com, ensure
    you quote enough for the article to make sense. Google is only
    an interface to Usenet; it's not Usenet itself. Don't assume
    your readers can, or ever will, see any previous articles.
    More details at: <http://cfaj.freeshell.org/google/>
     
    CBFalconer, Feb 11, 2007
    #16
  17. gert

    Flash Gordon Guest

    gert wrote, On 11/02/07 19:54:
    > On Feb 11, 7:29 pm, "gert" <> wrote:


    <snip>

    >> /home/gert/Desktop/svn/db/cgi/header.cgi: error while loading shared
    >> libraries: libfcgi.so.0: cannot open shared object file: No such file
    >> or directory

    >
    > added /usr/local/lib to ldconfig


    Please stop posting your failures to use your tools correctly here. How
    to use your tools to link properly and how you do CGIs is not topical
    here. If you want help with the tools go to a group where your system is
    topical (probably a Linux group) and if you want help writing CGIs go
    where they are topical.
    --
    Flash Gordon
     
    Flash Gordon, Feb 11, 2007
    #17
  18. "gert" <> writes:
    > On Feb 11, 7:18 pm, "gert" <> wrote:
    >> Alelooia
    >>
    >> gcc -L/usr/lib/libfcgi.so -lfcgi -o Desktop/svn/db/cgi/header.cgi
    >> Desktop/svn/db/cgi/header.c
    >>
    >> And No i have no idea why it compiles or what the difference is
    >> between the big -L and the small -l :)
    >>
    >> I am just a little frustrated trying the hole weekend to display hello
    >> world om my browser
    >>
    >> If only my lighttpd webserver would now be nice enough to finaly run
    >> my cgi i would be happy.

    >
    > WHAAAAAAAAAAAAA going postal
    >
    > /home/gert/Desktop/svn/db/cgi/header.cgi: error while loading shared
    > libraries: libfcgi.so.0: cannot open shared object file: No such file
    > or directory


    Your compiler needs to find the necessary include files when you
    compile, *and* your linker needs to find the necessary libraries when
    you link, *and*, if you're using shared libraries of some sort, your
    executable needs to find the libraries at run time.

    The details of how to arrange this are *extremely* system-specific and
    not specified by the C langauge. Judging by the command's you're
    using, comp.unix.programmer would be the place to ask.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Feb 11, 2007
    #18
  19. Mark McIntyre wrote:
    > Gert, please understand that nobody is being unhelpful. Its just that
    > you're asking in the wrong place. You don't ask garage mechanics about
    > the price of wheat. You don't ask farmers about how to rebore a
    > straight 12 diesel.


    Any tractors with straight 12 diesels?
     
    Christopher Layne, Feb 12, 2007
    #19
  20. gert

    CBFalconer Guest

    Christopher Layne wrote:
    > Mark McIntyre wrote:
    >
    >> Gert, please understand that nobody is being unhelpful. Its just
    >> that you're asking in the wrong place. You don't ask garage
    >> mechanics about the price of wheat. You don't ask farmers about
    >> how to rebore a straight 12 diesel.

    >
    > Any tractors with straight 12 diesels?


    6 Kubukus in a row.

    --
    <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
    <http://www.securityfocus.com/columnists/423>

    "A man who is right every time is not likely to do very much."
    -- Francis Crick, co-discover of DNA
    "There is nothing more amazing than stupidity in action."
    -- Thomas Matthews
     
    CBFalconer, Feb 12, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Felipe
    Replies:
    3
    Views:
    454
    Felipe
    Jul 16, 2004
  2. Lu
    Replies:
    1
    Views:
    589
    Roel Schroeven
    Jul 10, 2003
  3. Mantorok Redgormor
    Replies:
    70
    Views:
    1,805
    Dan Pop
    Feb 17, 2004
  4. VK
    Replies:
    45
    Views:
    629
    Dr John Stockton
    Sep 12, 2006
  5. -Lost
    Replies:
    13
    Views:
    381
    Richard Cornford
    Jan 31, 2007
Loading...

Share This Page