##include <curl/curl.h> not found

1 messages · Page 1 of 1 (latest)

slow wagon
#

Hello, i installed curl for do some web request but when im running the code im getting an error and i dont know how to fix it (i asked to chat gpt)
(i copied a code from chat gpt to test)

#include <stdio.h>
#include </Curl/curl.h>
//#include </Curl/types.h>
//#include </Curl/easy.h>


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

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");

        // Set the data to send
        char *data = "name=value";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

        // Perform the request
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));
        }

        // Clean up
        curl_easy_cleanup(curl);
    }
    return 0;
}

Thanks if you are gonna help me

dire hemlockBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

tardy drift
#

maybe ask it how to install curl

wraith dock
slow wagon
wraith dock
storm brook
#

C:\Curl isnt in your compiler's include path

dire hemlockBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.

slow wagon
# wraith dock It means read the documentation

i just followed a tutorial and got an error, in the tutorial it was working

#include <stdio.h>
#include "/curl/curl.h"

int main(void) {
    CURL *curl;
    CURLcode response;

    curl_global_init(CURL_GLOBAL_ALL);

    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "http://calapi.inadiutorium.cz/api/v0/en/calendars/general-en/2021/03");

        response = curl_easy_perform(curl);

        if(response != CURLE_OK) {
            fprintf(stderr, "Request failed: %s\n", curl_easy_strerror(response));
        } else {
            printf("%s", response);
        }
        curl_easy_cleanup(curl);
    }
    curl_global_cleanup();
    return 0;
}```
#

C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0xca): undefined reference to `_imp__curl_global_init' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0xd1): undefined reference to `_imp__curl_easy_init' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0x106): undefined reference to `_imp__curl_easy_setopt' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0x114): undefined reference to `_imp__curl_easy_perform' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0x12d): undefined reference to `_imp__curl_easy_strerror' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0x16d): undefined reference to `_imp__curl_easy_cleanup' C:\Users\SALAHE~1\AppData\Local\Temp\ccu2XemT.o:main.c:(.text+0x174): undefined reference to `_imp__curl_global_cleanup' collect2.exe: error: ld returned 1 exit status

#

i put the curl folder on C:\

slow wagon
wraith dock
#

Then you either didn't correctly link the library correctly or install it

slow wagon
#

it look like good in curl folder

#

how i correctly link the library ?

wraith dock
shrewd marsh
wraith dock
#

No / at the beginning

wraith dock
slow wagon
wraith dock
dire hemlockBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.