Closed kubrt22 closed 2 weeks ago
@kubrt22 thanks for reporting. This sounds like not providing the correct lib paths. Take a look at this issue: https://github.com/libcpr/cpr/issues/1034#issuecomment-2027085481
If the error then still persists, let me know :)
Fixed the compilation, now it doesnt give any errors:
g++ -o main main.cpp -std=c++20 -IC:\Dev\vcpkg\installed\x64-mingw-static\include -LC:\Dev\vcpkg\installed\x64-mingw-static\lib -lcpr -lcurl -lzlib -lssl -lcrypto -lbcrypt -lcrypt32 -lwsock32 -lws2_32
I needed to add the -lzlib -lbcrypt -lcrypt32 -lwsock32 -lws2_32
(thanks for the link to the #1034 issue)
But now when i run the executable it will print the r.status_code
as 0 instead of 200:
cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass", cpr::AuthMode::BASIC},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
std::cout << r.status_code << std::endl; // 200
Happens only on this example, other sites are working just fine
What does the following print:
if (s.status_code == 0) {
std::cout << s.error.code << ": " << s.error.message << "\n";
}
I cant print r.error.code
, it gives a lot of errors. r.error.message
is blank
What errors do you get?
main.cpp: In function 'int main(int, char**)':
main.cpp:11:19: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'cpr::ErrorCode')
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~~ ^~ ~~~~~~~~~~~~
| | |
| | cpr::ErrorCode
| std::ostream {aka std::basic_ostream<char>}
In file included from C:/mingw64/include/c++/13.2.0/iostream:41,
from main.cpp:1:
C:/mingw64/include/c++/13.2.0/ostream:110:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
110 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:110:36: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&
' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
110 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:119:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
119 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:119:32: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka
std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
119 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:129:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
129 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:129:30: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'std::ios_base& (*)(std::ios_base&)'
129 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:168:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits
= std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
168 | operator<<(long __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:168:23: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'long int'
168 | operator<<(long __n)
| ~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:172:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
172 | operator<<(unsigned long __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:172:32: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'long unsigned int'
172 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:176:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
176 | operator<<(bool __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:176:23: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'bool'
176 | operator<<(bool __n)
| ~~~~~^~~
In file included from C:/mingw64/include/c++/13.2.0/ostream:880:
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:183:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
183 | operator<<(unsigned short __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:183:33: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'short unsigned int'
183 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:194:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
194 | operator<<(unsigned int __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:194:31: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'unsigned int'
194 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:203:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
203 | operator<<(long long __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:203:28: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'long long int'
203 | operator<<(long long __n)
| ~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:207:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT =
char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
207 | operator<<(unsigned long long __n)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:207:37: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'long long unsigned int'
207 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:222:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits =
std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
222 | operator<<(double __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:222:25: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'double'
222 | operator<<(double __f)
| ~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:226:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
226 | operator<<(float __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:226:24: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'float'
226 | operator<<(float __f)
| ~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:234:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
234 | operator<<(long double __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:234:30: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'long double'
234 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:292:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
292 | operator<<(const void* __p)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:292:30: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'const void*'
292 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
C:/mingw64/include/c++/13.2.0/ostream:297:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
297 | operator<<(nullptr_t)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:297:18: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'std::nullptr_t'
297 | operator<<(nullptr_t)
| ^~~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:124:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]'
124 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:125:34: note: no known conversion for argument 1 from 'cpr::ErrorCode' to 'std::basic_ostream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'}
125 | operator<<(__streambuf_type* __sbin)
| ~~~~~~~~~~~~~~~~~~^~~~~~
In file included from C:/mingw64/include/c++/13.2.0/bits/basic_string.h:47,
from C:/mingw64/include/c++/13.2.0/string:54,
from C:/mingw64/include/c++/13.2.0/bits/locale_classes.h:40,
from C:/mingw64/include/c++/13.2.0/bits/ios_base.h:41,
from C:/mingw64/include/c++/13.2.0/ios:44,
from C:/mingw64/include/c++/13.2.0/ostream:40:
C:/mingw64/include/c++/13.2.0/string_view:760:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)'
760 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/string_view:760:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/bits/basic_string.h:4020:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT,
_Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4020 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/basic_string.h:4020:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
In file included from C:/mingw64/include/c++/13.2.0/bits/memory_resource.h:38,
from C:/mingw64/include/c++/13.2.0/string:58:
C:/mingw64/include/c++/13.2.0/cstddef:124:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)'
124 | operator<<(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/cstddef:124:5: note: template argument deduction/substitution failed:
main.cpp:11:14: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
11 | std::cout << r.error.code << std::endl;
| ~~~~~^~~~
In file included from C:/mingw64/include/c++/13.2.0/bits/ios_base.h:46:
C:/mingw64/include/c++/13.2.0/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/system_error:339:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const std::error_code&'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:554:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
554 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:554:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: deduced conflicting types for parameter '_CharT' ('char' and 'cpr::ErrorCode')
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:564:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
564 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:564:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'char'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:570:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
570 | operator<<(basic_ostream<char, _Traits>& __out, char __c)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:570:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'char'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:581:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
581 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:581:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'signed char'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:586:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
586 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:586:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'unsigned char'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, wchar_t)' (deleted)
595 | operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:595:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'wchar_t'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:600:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char8_t)' (deleted)
600 | operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:600:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'char8_t'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:605:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char16_t)' (deleted)
605 | operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:605:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'char16_t'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:609:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char32_t)' (deleted)
609 | operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:609:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'char32_t'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:615:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, char8_t)' (deleted)
615 | operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:615:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:620:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, char16_t)' (deleted)
620 | operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:620:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:624:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, char32_t)' (deleted)
624 | operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:624:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:645:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
645 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:645:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'const _CharT*' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const char*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:662:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
662 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:662:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const char*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:675:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)'
675 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:675:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const signed char*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:680:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)'
680 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:680:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const unsigned char*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const wchar_t*)' (deleted)
689 | operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:689:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const wchar_t*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:694:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char8_t*)' (deleted)
694 | operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:694:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const char8_t*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:699:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char16_t*)' (deleted)
699 | operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:699:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const char16_t*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:703:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char32_t*)' (deleted)
703 | operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:703:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'const char32_t*'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/ostream:709:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*)' (deleted)
709 | operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:709:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:714:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*)' (deleted)
714 | operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:714:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:718:5: note: candidate: 'template<class _Traits> std::basic_ostream<wchar_t, _Traits>& std::operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*)' (deleted)
718 | operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:718:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'wchar_t' and 'char'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/ostream:801:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)'
801 | operator<<(_Ostream&& __os, const _Tp& __x)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/ostream:801:5: note: template argument deduction/substitution failed:
C:/mingw64/include/c++/13.2.0/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_ostream<char>&; _Tp = cpr::ErrorCode]':
main.cpp:11:30: required from here
C:/mingw64/include/c++/13.2.0/ostream:801:5: error: template constraint failure for 'template<class _Os, class _Tp> requires (__derived_from_ios_base<_Os>) && requires(_Os& __os, const _Tp& __t) {__os << __t;} using std::__rvalue_stream_insertion_t = _Os&&'
C:/mingw64/include/c++/13.2.0/ostream:801:5: note: constraints not satisfied
C:/mingw64/include/c++/13.2.0/ostream: In substitution of 'template<class _Os, class _Tp> requires (__derived_from_ios_base<_Os>) && requires(_Os& __os, const _Tp& __t) {__os << __t;} using std::__rvalue_stream_insertion_t = _Os&& [with _Os = std::basic_ostream<char>&; _Tp = cpr::ErrorCode]':
C:/mingw64/include/c++/13.2.0/ostream:801:5: required by substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_ostream<char>&; _Tp = cpr::ErrorCode]'
main.cpp:11:30: required from here
C:/mingw64/include/c++/13.2.0/ostream:768:13: required for the satisfaction of '__derived_from_ios_base<_Os>' [with _Os = std::basic_ostream<char, std::char_traits<char> >&]
C:/mingw64/include/c++/13.2.0/ostream:768:39: note: the expression 'is_class_v<_Tp> [with _Tp = std::basic_ostream<char, std::char_traits<char> >&]' evaluated to 'false'
768 | concept __derived_from_ios_base = is_class_v<_Tp>
| ^~~~~~~~~~~~~~~
In file included from C:/mingw64/include/c++/13.2.0/bits/shared_ptr_base.h:59,
from C:/mingw64/include/c++/13.2.0/bits/shared_ptr.h:53,
from C:/mingw64/include/c++/13.2.0/condition_variable:45,
from C:/mingw64/include/c++/13.2.0/future:41,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/api.h:6,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/cpr.h:4,
from main.cpp:3:
C:/mingw64/include/c++/13.2.0/bits/unique_ptr.h:1142:5: note: candidate: 'template<class _CharT, class _Traits, class _Tp, class _Dp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const unique_ptr<_Up, _Ep>&) requires requires{std::operator<<::__os << std::operator<<::__p->get();}'
1142 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/unique_ptr.h:1142:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'const std::unique_ptr<_Up, _Ep>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)'
70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os,
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'const std::__shared_ptr<_Tp, _Lp>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
In file included from C:/mingw64/include/c++/13.2.0/bits/chrono_io.h:38,
from C:/mingw64/include/c++/13.2.0/chrono:3330,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/cookies.h:5,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/response.h:12,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/async_wrapper.h:8,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/async.h:4,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/api.h:10:
C:/mingw64/include/c++/13.2.0/iomanip:81:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Resetiosflags)'
81 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:81:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::_Resetiosflags'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/iomanip:111:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Setiosflags)'
111 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:111:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::_Setiosflags'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/iomanip:145:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Setbase)'
145 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:145:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::_Setbase'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/iomanip:180:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Setfill<_CharT>)'
180 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:180:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'std::_Setfill<_CharT>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/iomanip:210:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Setprecision)'
210 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:210:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::_Setprecision'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/iomanip:240:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Setw)'
240 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:240:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::_Setw'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
C:/mingw64/include/c++/13.2.0/iomanip:313:5: note: candidate: 'template<class _CharT, class _Traits, class _MoneyT> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Put_money<_MoneyT>)'
313 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:313:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'std::_Put_money<_MoneyT>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
C:/mingw64/include/c++/13.2.0/iomanip:365:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _Put_time<_CharT>)'
365 | operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/iomanip:365:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'std::_Put_time<_CharT>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
In file included from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/threadpool.h:13,
from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/async.h:6:
C:/mingw64/include/c++/13.2.0/thread:97:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, thread::id)'
97 | operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id)
| ^~~~~~~~
C:/mingw64/include/c++/13.2.0/thread:97:5: note: template argument deduction/substitution failed:
main.cpp:11:30: note: cannot convert 'r.cpr::Response::error.cpr::Error::code' (type 'cpr::ErrorCode') to type 'std::thread::id'
11 | std::cout << r.error.code << std::endl;
| ~~~~~~~~^~~~
In file included from C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/response.h:13:
C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/cprtypes.h:112:15: note: candidate: 'template<class T> std::ostream& cpr::operator<<(std::ostream&, const StringHolder<T>&)'
112 | std::ostream& operator<<(std::ostream& os, const StringHolder<T>& s) {
| ^~~~~~~~
C:\Dev\vcpkg\installed\x64-mingw-static\include/cpr/cprtypes.h:112:15: note: template argument deduction/substitution failed:
main.cpp:11:30: note: mismatched types 'const cpr::StringHolder<T>' and 'cpr::ErrorCode'
11 | std::cout << r.error.code << std::endl;
| ^~~~
make: *** [main] Error 1
The error code is an enum value. Try casting it to an unsigned e.g. std::cout << static_cast<uint>(s.error.code) << ": " << s.error.message << "\n";
Looks like your compiler can not automatically convert it.
I get 4:
, the error code is 4 and message empty
4 means "internal error". I tried it on my Windows machine and I can not reproduce it. I suspect it has to do something with the TLS connection. To confirm this you can try it on an http website.
Looks like http works fine, every page i have tried besides github for some reason works and the main issue was fixed, so i will close this and thanks for the help.
Description
I get a lot of errors when try to compile using Makefile on Windows. I tried static and dynamic libs (both from vcpkg), with both i get errors (different errors).
Makefile:
Main.cpp
Build output from dynamic libs
Static build:
Example/How to Reproduce
Possible Fix
Link something ig
Where did you get it from?
vcpkg
Additional Context/Your Environment