cURL / Mailing Lists / curl-library / Single Mail

curl-library

library path or makefile issue?

From: <theexperts_at_allprodirect.com>
Date: Sat, 23 Mar 2002 01:26:32 -0500

(Re-posting this to the CORRECT list this time! Sorry!)

Maybe my last email wasn't so accurate. It was a hard day's night, I had
been working like a dog, and truth be told, I really should have been
sleeping like a log. ;-)

The story of my odyssey may help others, especially those in a virtual web
server environment. Hey, maybe this could be edited into a "step-by-step
getting started with curl" guide!

So here's a fairly detailed rundown:

downloaded http://curl.haxx.se/download/curl-7.9.5.tar.gz

uploaded to web server, telnetted in and gunzipped it

this is a virtual web server account on a shared computer at my web hosting
provider

went into newly created folder 'curl-7.9.5' and typed 'make' (enter)

lengthy make process ensued (my first experience with 'make') which scrolled
many messages accross my virual terminal display

one message was along the lines of: your version of gcc (2.8.1) is not the
latest version (3.0). It is highly recommended that you upgrade to the
latest version. At least you will be able to ... the libraries.

made some necessary changes to curl.h:
line 52: #include </home/myfolder/curl-7.9.5/include/curl/types.h>
line 681: #include </home/myfolder/curl-7.9.5/include/curl/easy.h>

I copied an example source code from the curl web site:
http://curl.haxx.se/lxr/source/docs/examples/simple.c

made some necessary changes to it (i.e. remove line numbers and change url)
resulting in test.c:

========================
#include <stdio.h>
// #include </home/myfolder/curl-7.9.5/include/curl/curl.h>

int main()
{
// CURL *curl;
// CURLcode res;

printf("Start\n");

/*
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_VERBOSE, "1");
    curl_easy_setopt(curl, CURLOPT_URL, "www.yahoo.com");
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
*/

printf("Finish\n");

  return 0;
}
========================

compile it with: gcc -o test.cgi test.c

compiles with no errors.

set file permissions: chmod 755 test.cgi
set folder permissions: chmod 755 c

call it from a php script:

========================
<?
echo "not done.<br>";
exec("/home/1source/public_html/c/test.cgi", $out);
foreach ($out as $put) {
  $i++;
  echo "$i $put";
}
echo "<br>done.";
?>
========================

It produces the following output:

========================
not done.
1 Start
2 Finish

done.
========================

Newsflash: I think I have narrowed the problem down to the compile
command!!!

curl-config --cflags:
-I/usr/local/include

curl-config --cflags:
-L/usr/local/lib -lcurl -L/usr/local/ssl2/lib -lssl -lcrypto -ldl -lsocket -
lnsl

compile it with: gcc -o test.cgi
test.c -I/usr/local/include -L/usr/local/lib -lcurl -L/usr/local/ssl2/lib -l
dl -lsocket -lnsl

compiles with no errors.

however, it produces no output:

========================
not done.

done.
========================

So it seems that either having too much in the compile line can cause it to
compile wrong, or I am grabbing the wrong library item somewhere.

So when I un-comment-out the references to curl in the c source code, I
think the compile line is still wrong and causing the problem. But no
messages from the compiler? Hmm...

I tried it with other library references removed, with no success. So I
think it is a matter of grabbing the wrong library file with the same name
from a different folder.

Note: the compile command fails with "-lssl -lcrypto" in it.
ld: fatal: library -lssl: not found
ld: fatal: library -lcrypto: not found
ld: fatal: File processing errors. No output written to test.cgi

I don't require ssl at this time.

Well, I hope that is thorough enough! 8^)

Recent developments:

All this thoroughness made me realize: the paths are wrong! Try:

gcc -o test.cgi
test.c -I/home/myfolder/curl-7.9.5/include -L/home/myfolder/curl-7.9.5/lib -
lcurl

Compiles but still doesn't work.

Try with: -ldl -lsocket -lnsl

Nope.

Okay, I think I'm on the right track but still stuck.

Many thanks to anyone for any help.

-J.

Maybe these excerpts from config.log will shed some light on this issue:

========================
configure:8024: gcc -o conftest -g -O2 conftest.c >&5
Undefined first referenced
 symbol in file
gethostbyname /var/tmp/ccoYaqeM1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:8027: $? = 1
configure: failed program was:
#line 7993 "configure"

configure:8743: gcc -o conftest -g -O2 conftest.c -lsocket -lnsl >&5
Undefined first referenced
 symbol in file
dlclose /var/tmp/cc5yaWvM1.o (symbol belongs to
implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to conftest
configure:8746: $? = 1
configure: failed program was:
#line 8712 "configure"

configure:9903: gcc -o conftest -g -O2
  conftest.c -lcrypto -ldl -lsocket -lnsl >&5
ld: fatal: library -lcrypto: not found
ld: fatal: File processing errors. No output written to conftest
configure:9906: $? = 1
configure: failed program was:
#line 9884 "configure"

configure:9962: gcc -o
onftest -g -O2 -I/include/openssl -I/include -L/lib
onftest.c -lcrypto -ldl -lsocket -lnsl >&5
ld: fatal: library -lcrypto: not found
ld: fatal: File processing errors. No output written to conftest
configure:9965: $? = 1
configure: failed program was:
#line 9943 "configure"

configure:10388: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
RAND_status /var/tmp/ccWDaqJM1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:10391: $? = 1
configure: failed program was:
#line 10357 "configure"

configure:10388: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
RAND_screen /var/tmp/cc.YaGMM1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:10391: $? = 1
configure: failed program was:
#line 10357 "configure"

configure:10388: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
RAND_egd /var/tmp/ccRia4OM1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:10391: $? = 1
configure: failed program was:
#line 10357 "configure"

configure:10529: gcc -c -g -O2 conftest.c >&5
configure:10516: warning: `struct hostent_data' declared inside parameter
list
configure:10516: warning: its scope is only this definition or declaration,
configure:10516: warning: which is probably not what you want.
configure:10516: conflicting types for `gethostbyname_r'
/usr/include/netdb.h:146: previous declaration of `gethostbyname_r'
configure: In function `main':
configure:10521: storage size of `data' isn't known
configure:10532: $? = 1
configure: failed program was:
#line 10507 "configure"

configure:10581: gcc -c -g -O2 conftest.c >&5
configure:10568: warning: `struct hostent_data' declared inside parameter
list
configure:10568: warning: its scope is only this definition or declaration,
configure:10568: warning: which is probably not what you want.
configure:10568: conflicting types for `gethostbyname_r'
/usr/include/netdb.h:146: previous declaration of `gethostbyname_r'
configure: In function `main':
configure:10573: storage size of `data' isn't known
configure:10584: $? = 1
configure: failed program was:
#line 10557 "configure"

configure:10817: gcc -c -g -O2 conftest.c >&5
configure: In function `main':
configure:10808: storage size of `hdata' isn't known
configure:10810: too few arguments to function `gethostbyaddr_r'
configure:10810: warning: assignment makes integer from pointer without a
cast
configure:10820: $? = 1
configure: failed program was:
#line 10796 "configure"

configure:10867: gcc -c -g -O2 conftest.c >&5
configure: In function `main':
configure:10858: storage size of `hdata' isn't known
configure:10860: too few arguments to function `gethostbyaddr_r'
configure:10860: warning: assignment makes integer from pointer without a
cast
configure:10870: $? = 1
configure: failed program was:
#line 10845 "configure"

configure:11487: checking for io.h
configure:11497: gcc -E conftest.c
configure:11494: io.h: No such file or directory
configure:11503: $? = 1
configure: failed program was:
#line 11493 "configure"

configure:11722: checking for stdint.h
configure:11734: gcc -c -g -O2 conftest.c >&5
configure:11763: stdint.h: No such file or directory
configure:11737: $? = 1
configure: failed program was:
#line 11728 "configure"

configure:12285: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
stricmp /var/tmp/ccg8aO8P1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:12288: $? = 1
configure: failed program was:
#line 12254 "configure"

configure:12285: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
strcmpi /var/tmp/ccboai_P1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:12288: $? = 1
configure: failed program was:
#line 12254 "configure"

configure:12285: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
closesocket /var/tmp/cc6fa4AQ1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:12288: $? = 1
configure: failed program was:
#line 12254 "configure"

configure:12285: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
getpass_r /var/tmp/cchAaaNQ1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:12288: $? = 1
configure: failed program was:
#line 12254 "configure"

configure:12285: gcc -o conftest -g -O2 conftest.c -ldl -lsocket -lnsl
>&5
Undefined first referenced
 symbol in file
strlcat /var/tmp/cc2KaiPQ1.o
ld: fatal: Symbol referencing errors. No output written to conftest
configure:12288: $? = 1
configure: failed program was:
#line 12254 "configure"
========================
Received on 2002-03-23