undefined reference

G

gert

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$
 
G

gert

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;
}
 
A

artifact.one

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
 
M

Mark McIntyre

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
 
M

Mark McIntyre

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
 
G

gert

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.
 
G

gert

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
 
G

gert

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:~$
 
G

gert

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 ??????
 
M

Mark McIntyre

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
 
M

Mark McIntyre

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
 
M

Mark McIntyre

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
 
C

CBFalconer

gert said:
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/>
 
F

Flash Gordon

gert wrote, On 11/02/07 19:54:
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.
 
K

Keith Thompson

gert said:
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.
 
C

Christopher Layne

Mark said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top