Giter Club home page Giter Club logo

Comments (5)

codersguild avatar codersguild commented on May 17, 2024

The following C++ code gives the error.

#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <curlpp/cURLpp.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <mutex>

using std::operator""s;

namespace
{
    unsigned ln = 1;
    auto Color(int n, const std::string& s) { return "\33[38;5;"+std::to_string(n)+'m'+s+"\33[m"; }
    auto Line(int l) { int m=l-ln; ln=l; return "\r"+(m<0?"\33["+std::to_string(-m)+'A':std::string(m,'\n')); }
    std::mutex print_lock;

    std::size_t Download(const std::string& url, const std::string& filename, unsigned line)
    {
        std::ofstream of(filename);
        std::size_t written = 0;

        cURLpp::Easy req;
        req.setOpt(cURLpp::Options::Url(url));
        req.setOpt(cURLpp::Options::NoProgress(false));
        req.setOpt(cURLpp::Options::FollowLocation(true));
        req.setOpt(cURLpp::Options::ProgressFunction([&](std::size_t total, std::size_t done, auto...)
        {
            std::lock_guard<std::mutex> l(print_lock);
            std::cout << Line(line) << Color(143, filename + ": ") << done << " of " << total
                      << " bytes received (" << int(total ? done*100./total : 0) << "%)" << std::flush;
            return 0;
        }));
        req.setOpt(cURLpp::Options::WriteFunction([&](const char* p, std::size_t size, std::size_t nmemb)
        {
            of.write(p, size*nmemb);
            written += size*nmemb;
            return size*nmemb;
        }));
        req.perform();
        return written;
    }

    auto root = "http://iki.fi/bisqwit/ctu85/"s; // http://www.unicode.org/Public/MAPPINGS/ISO8859/
}

#include <future>

int main()
{
    cURLpp::initialize();
    unsigned line=1;

    std::vector<std::future<std::size_t>> sizes;

    for(const auto& p: {"8859-1.TXT"s, "8859-2.TXT"s, "8859-3.TXT"s, "8859-4.TXT"s, "8859-5.TXT"s,
                        "8859-6.TXT"s, "8859-7.TXT"s, "8859-8.TXT"s, "8859-9.TXT"s, "8859-10.TXT"s,
                        "8859-11.TXT"s,"8859-13.TXT"s,"8859-14.TXT"s,"8859-15.TXT"s,"8859-16.TXT"s})
    {
        sizes.emplace_back(std::async(std::launch::async, [p, l=line++]
        {
            return Download(root+p, p, l);
        }));
    }

    std::size_t total = 0;
    for(auto& s: sizes) total += s.get();

    std::cout << Line(line) << Color(174, std::to_string(total) + " bytes downloaded total\n");
}

from curlpp.

codersguild avatar codersguild commented on May 17, 2024

image

from curlpp.

kotaweav avatar kotaweav commented on May 17, 2024

Same problem here when I run:

#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <iostream>

int main() {
    try {
        curlpp::Cleanup cleanup;

        {
            std::cout << curlpp::options::Url("http://google.com");
        }
    } catch (curlpp::RuntimeError& e) {
        std::cout << e.what() << std::endl;
    } catch (curlpp::LogicError& e) {
        std::cout << e.what() << std::endl;
    }
}

Here is the error message:

CMakeFiles/ssr_server_connect_node.dir/src/main_node.cpp.o: In function `main':
main_node.cpp:(.text+0x67): undefined reference to `operator<<(std::ostream&, curlpp::OptionTrait<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, (CURLoption)10002> const&)'
CMakeFiles/ssr_server_connect_node.dir/src/main_node.cpp.o: In function `curlpp::OptionTrait<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, (CURLoption)10002>::updateHandleToMe(curlpp::internal::CurlHandle*) const':
main_node.cpp:(.text._ZNK6curlpp11OptionTraitINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE[_ZNK6curlpp11OptionTraitINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEL10CURLoption10002EE16updateHandleToMeEPNS_8internal10CurlHandleE]+0x68): undefined reference to `curlpp::UnsetOption::UnsetOption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/ssr_server_connect_node.dir/src/main_node.cpp.o: In function `curlpp::Option<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::getValue() const':
main_node.cpp:(.text._ZNK6curlpp6OptionINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8getValueEv[_ZNK6curlpp6OptionINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8getValueEv]+0x68): undefined reference to `curlpp::UnsetOption::UnsetOption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

from curlpp.

codersguild avatar codersguild commented on May 17, 2024

I had to do a hell lot of things to get the problem fixed. The order of linking matters. I copied the binary files in to a /usr/bin dir and includes into /usr/include. This is not one by default.

from curlpp.

codersguild avatar codersguild commented on May 17, 2024

Please work on the issue guys. It is a painstaking job to do it every time there is an issue with curlpp.

from curlpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.