Comments (5)
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.
from curlpp.
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.
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.
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)
- myRequest.setOpt<Url>() results in linker error "Unresolved External Symbol" HOT 1
- cURLpp linker errors HOT 1
- setOpt() const parameters HOT 1
- Error LNK2019 unresolved external symbol __imp_curl_easy_setopt HOT 7
- How do i use this in visual studio HOT 3
- Update Nuget Package HOT 3
- How to download zip file HOT 3
- Response from the server
- Clion build project HOT 1
- hi , base on c : curl
- Some culpp options should be defined as this HOT 1
- run error about clone_ptr HOT 1
- [question]how to use progressfunction to get upload or download progress value HOT 2
- abnormal upload speed and size HOT 3
- [cmake] A required package was not found
- Is curlpp support async rest? HOT 1
- Linker error when using curlpp HOT 1
- Assessment of the difficulty in porting CPU architecture for the curlpp
- how to construct a put request?
- how to construct a put request? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curlpp.