cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: Re: Re: Now I am facing the error only when the filesize is mentioned with CURLOPT_INFILESIZ

From: azad amm <ammazad_at_rediffmail.com>
Date: 20 Jan 2006 12:41:05 -0000

Well I may not be inclined right now to determine the define to be set. However i have this finding, this program a.c with the following code and compiled it with -m64 options and without the -m64 options (gcc compiler) i get different outputs for the sizeof(curl_off_t) bash-2.05# cat a.c #include <stdio.h> #include <curl/curl.h> int main() { printf("%d %d %d %d\n", sizeof(long), sizeof(int), sizeof(off_t), sizeof(curl_off_t)); } bash-2.05# gcc -o prog a.c bash-2.05# ./prog 4 4 4 4 bash-2.05# gcc -m64 -o prog a.c bash-2.05# ./prog 8 4 8 8 But when i try to compile the following ftpupload.c program with -m64 option, I get an error like this... What does this mean?? Is it that when i ran the make script while installing libcurl, I didnt use -m64 option?? bash-2.05# gcc -m64 -o prog -I/usr/local/include -L/usr/local/lib -lcurl -L/usr/local/ssl/lib -lssl -lcrypto -ldl -lsocket -lnsl -lz ftpupload.c ld: fatal: file /usr/local/lib/libcurl.so: wrong ELF class: ELFCLASS32 ld: fatal: File processing errors. No output written to prog collect2: ld returned 1 exit status bash-2.05# cat ftpupload.c #include <stdio.h> #include <curl/curl.h> #define TRUE 1 #define LOCAL_FILE "a.txt" #define REMOTE_URL "ftp://bridge/a.txt" struct FtpFile { char *filename; FILE *stream; }; int my_fread(void *buffer, size_t size, size_t nmemb, void *stream) { struct FtpFile *out=(struct FtpFile *)stream; if(out && !out->stream) { /* open file for reading */ out->stream=fopen(out->filename, "rb"); if(!out->stream) return -1; /* failure, can't open file to read */ } return fread(buffer, size, nmemb, out->stream); } int main(int argc, char **argv) { CURL *curl; CURLcode res; char passwd[] = "hemant:sample"; struct FtpFile ftpfile={ "a.txt", /* name to store the file as if succesful */ NULL }; printf("%ld\n", sizeof(curl_off_t)); printf("%ld\n", sizeof(off_t)); /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); /* get a curl handle */ curl = curl_easy_init(); if(curl) { /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; /* specify target */ curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL); curl_easy_setopt(curl, CURLOPT_USERPWD, passwd); curl_easy_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_ALL); /* Define our callback to get called when there's data to be read */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_fread); /* now specify which file to upload */ curl_easy_setopt(curl, CURLOPT_READDATA, &ftpfile); curl_easy_setopt(curl, CURLOPT_INFILESIZE,(long)3); curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); } curl_global_cleanup(); return 0; } On Thu, 19 Jan 2006 Daniel Stenberg wrote : >On Thu, 19 Jan 2006, azad amm wrote: > >>Now, i am able to find out that curl_off_t is 32bit in my app, with printf("%d\n", sizeof(curl_off_t)); > >>How do i find out the sizeof curl_off_t in libcurl? > >It isn't that easy to probe, but from the output in your error case we know this. The number '12884973312' is larger than what fits within 32 bits. > >I find it strange that your curl_off_t is 32 bit only. You think you can research why it happens? In the curl headers, it tries to include the necessary files to find your system's off_t type and then curl_off_t is set to use that type. > >On all modern unixes, off_t is 64 bit. Possibly there needs to be some define set? > >-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-01-20