Yawning Gull
Yawning Gull

Reputation: 11

LNK2019 Error using libcurl

I've been getting this error for a while now, so as a last resort I followed This video to the letter.. and still got the same errors. So, here's the code I produced:

#include <iostream>
#include <string>

#define CURL_STATIC
#include "curl/curl.h"

#ifdef _DEBUG
#   pragma comment (lib, "curl/libcurl_a_debug.lib")
#else
#   pragma comment (lib, "curl/libcurl_debug.lib")
#endif

static int writer(char *data, size_t size, size_t nmemb,
    std::string *writerData)
{
    if (writerData == NULL)
        return 0;

    writerData->append(data, size*nmemb);

    return size * nmemb;
}


int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
    std::cout << "Hello curl!";

    std::string content;

    curl_global_init(CURL_GLOBAL_ALL);

    CURL *curl = nullptr;

    curl = curl_easy_init();

    if (curl)
    {
        curl_easy_setopt(curl, CURLOPT_URL, "https://www.youtube.com/watch?v=wjNyT5PhNvI&t=417s");
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
        CURLcode code = curl_easy_perform(curl);

        curl_easy_cleanup(curl);

    }

    curl_global_cleanup();

    std::cout << content;

    std::cin.get();
}

And the errors:

1>------ Build started: Project: curl_test, Configuration: Debug Win32 ------
1>main.cpp
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_global_cleanup referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _wmain
1>c:\users\james\source\repos\curl_test\Debug\curl_test.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "curl_test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Does anyone know what could be causing this? The Linker susbsytem is set to console, the character set is set to unicode, and MFC is set to be used in a static library.

Upvotes: 1

Views: 3140

Answers (1)

Gavin
Gavin

Reputation: 21

Do you miss Ws2_32.lib, Crypt32.lib, Wldap32.lib and Normaliz.lib?

Upvotes: 0

Related Questions