Reputation: 1527
recently managed to use a libcurl in a test program for downloading a files. The code is this:
CURL * curl;
FILE * fout;
CURLcode result;
char * url = "http://blablabla.com/blablabla.txt";
char filename[FILENAME_MAX] = "blablabla.txt";
curl = curl_easy_init();
if (curl)
{
fout = fopen(filename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fout);
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fout);
}
and those things for directives:
#define CURL_STATICLIB
#include <curl/curl.h>
My question is how to make that I don't need to copy all of its dlls in the same dir with the exec to make it work:
libcurl.dll
libeay32.dll
libidn-11.dll
librtmp.dll
libssh2.dll
libssl32.dll
zlib1.dll
Cannot find info about that in the homesite (http://curl.haxx.se) of the library :|
Upvotes: 5
Views: 10208
Reputation: 82
CURL *curl;
CURLcode res;
CString strUser;
FILE *ftplister;
m_FTPUserName.GetWindowTextW (strUser);
CT2CA PUF_File_HostName(PUF_FIle_Host);
CT2CA FTP_UserName(FTP_USERNAME);
FTP_PASSWORD.Append(L":");
FTP_PASSWORD.Append(FTP_USERNAME);
CT2CA FTP_Password(FTP_PASSWORD);
CT2CA FTP_AddressName(FTP_Address);
CString strLocalFile;
CString strFileName;
m_FTPFileName.GetWindowTextW(strFileName);
strLocalFile.Append(FTP_FileName);
strLocalFile.Append(L"\\");
strLocalFile.Append(strFileName);
CT2CA PUF_LocalFile(strLocalFile);
//ofstream stream2(PUF_LocalFile);
curl = curl_easy_init();
if(curl)
{
ftplister=fopen(PUF_LocalFile,"wb");
curl_easy_setopt(curl,CURLOPT_URL,PUF_File_HostName);
if(strUser!=_T(""))
{
curl_easy_setopt(curl,CURLOPT_USERPWD,FTP_Password);
}
curl_easy_setopt(curl, CURLOPT_FTP_SSL, TRUE);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ftplister);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(ftplister);
}
Upvotes: -3
Reputation: 385405
You mean, "how do I statically link libcurl"?
5.7 in the FAQ says:
When building an application that uses the static libcurl library, you must add
-DCURL_STATICLIB
to yourCFLAGS
. Otherwise the linker will look for dynamic import symbols. If you're using Visual Studio, you need to instead addCURL_STATICLIB
in the "Preprocessor Definitions" section.
Upvotes: 13