`Я загрузил curl-8.6.0 и распаковал его в папку. У меня есть программа, и мне нужно связать ее с библиотекой
Моя папка библиотеки Curl
Код: Выделить всё
C:.
└───curl-8.6.0
├───CMake
│ └───Platforms
├───docs
│ ├───cmdline-opts
│ ├───examples
│ └───libcurl
│ └───opts
├───include
│ └───curl
├───lib
│ ├───vauth
│ ├───vquic
│ ├───vssh
│ └───vtls
├───m4
├───packages
│ ├───OS400
│ │ └───rpg-examples
│ └───vms
├───plan9
│ ├───include
│ ├───lib
│ └───src
├───projects
│ └───Windows
│ ├───VC14
│ │ ├───lib
│ │ └───src
│ ├───VC14.10
│ │ ├───lib
│ │ └───src
│ ├───VC14.20
│ │ ├───lib
│ │ └───src
│ └───VC14.30
│ ├───lib
│ └───src
├───scripts
├───src
├───tests
│ ├───certs
│ │ └───scripts
│ ├───data
│ ├───http
│ │ └───clients
│ ├───libtest
│ ├───server
│ └───unit
└───winbuild
Код: Выделить всё
#include
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/8.5.0");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may choose to either not use them or implement
them yourself.
CURLOPT_WRITEDATA was set to an object pointer
CURLOPT_INTERLEAVEDATA was set to an object pointer
CURLOPT_WRITEFUNCTION was set to a function pointer
CURLOPT_READDATA was set to an object pointer
CURLOPT_READFUNCTION was set to a function pointer
CURLOPT_SEEKDATA was set to an object pointer
CURLOPT_SEEKFUNCTION was set to a function pointer
CURLOPT_ERRORBUFFER was set to an object pointer
CURLOPT_STDERR was set to an object pointer
CURLOPT_HEADERFUNCTION was set to a function pointer
CURLOPT_HEADERDATA was set to an object pointer
*/
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
return (int)ret;
}
Код: Выделить всё
C:\curltest>gcc -Wall -std=c99 -o my_program -IC:\curllll\curl-8.6.0\include -LC:\curllll\curl-8.6.0\lib main.c -lcurl
C:/Mingw64posix/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl
collect2.exe: error: ld returned 1 exit status
I am so hopeless. Help me.
I have ask the chat gpt and receive the following result
The error message cannot find -lcurl suggests that the linker is unable to locate the libcurl library file (libcurl.a or libcurl.so). This can happen if the library directory (C:\curllll\curl-8.6.0\lib) is not correctly specified or if the libcurl library file is missing.
Here are some steps to troubleshoot and fix the issue:
Check the Library Directory: Verify that the path to the libcurl library directory is correct (C:\curllll\curl-8.6.0\lib). Ensure that this directory contains the libcurl library file (libcurl.a or libcurl.so).
Library File Name: Depending on your system, the libcurl library file may have different names such as libcurl.a, libcurl.so, or libcurl.lib. Make sure the file exists in the library directory and has the correct name.
Specify Full Path to Library: Instead of relying on the -L option alone to specify the library directory, you can also try providing the full path to the libcurl library file directly using the -l option. For example, -LC:\curllll\curl-8.6.0\lib -lC:\curllll\curl-8.6.0\lib\libcurl.a.
`
Источник: https://stackoverflow.com/questions/781 ... to-program