Включить или связать внешнюю библиотеку libcurl с программойC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Гость
 Включить или связать внешнюю библиотеку libcurl с программой

Сообщение Гость »


`Я загрузил 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

мой main.c

Код: Выделить всё

#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
Why my gcc can not find my library.
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
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Ошибка cURL 60: см. http://curl.haxx.se/libcurl/c/libcurl-errors.html.
    Anonymous » » в форуме Php
    0 Ответы
    42 Просмотры
    Последнее сообщение Anonymous
  • Ошибка курения 60: см. http://curl.haxx.se/libcurl/c/libcurl-errors.html
    Anonymous » » в форуме Php
    0 Ответы
    36 Просмотры
    Последнее сообщение Anonymous
  • Ошибка курения 60: см. http://curl.haxx.se/libcurl/c/libcurl-errors.html
    Anonymous » » в форуме Php
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous
  • CMake связать внешнюю общую библиотеку в Linux?
    Anonymous » » в форуме C++
    0 Ответы
    16 Просмотры
    Последнее сообщение Anonymous
  • Цифон не может связать внешнюю библиотеку
    Anonymous » » в форуме Python
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C++»