-5

I am working on a software with the binance cpp api.

Now i got the problem that on my raspian and codeblocks installed i cannot use the provided pre-compiled .so library for the binacpp header.

So i read that i need to compile it for my system and tried to run make via terminal now this happened:

pi@raspberrypi:~/Desktop/patch/src $ make
g++ -I../lib/libcurl-7.56.0/include -I../lib/jsoncpp-1.8.3/include -c binacpp.cpp  -fPIC   -o ../lib/libbinacpp/lib/binacpp.o 
binacpp.cpp: In static member function ‘static void BinaCPP::send_order(const char*, const char*, const char*, const char*, double, double, const char*, double, double, long int, Json::Value&)’:
binacpp.cpp:909:39: error: call of overloaded ‘to_string(double&)’ is ambiguous
  post_data.append( to_string( quantity) );
                                       ^
In file included from binacpp.cpp:16:0:
binacpp_utils.h:28:15: note: candidate: std::__cxx11::string to_string(const T&) [with T = double; std::__cxx11::string = std::__cxx11::basic_string<char>]
 inline string to_string (const T& t)
               ^~~~~~~~~
binacpp_utils.h:36:20: note: candidate: std::__cxx11::string to_string(double)
 static std::string to_string(double val)
                    ^~~~~~~~~
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from binacpp.h:19,
                 from binacpp.cpp:14:
/usr/include/c++/6/bits/basic_string.h:5522:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5513:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5504:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5498:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5492:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5486:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5481:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5475:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5470:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
binacpp.cpp:912:36: error: call of overloaded ‘to_string(double&)’ is ambiguous
  post_data.append( to_string( price) );
                                    ^
In file included from binacpp.cpp:16:0:
binacpp_utils.h:28:15: note: candidate: std::__cxx11::string to_string(const T&) [with T = double; std::__cxx11::string = std::__cxx11::basic_string<char>]
 inline string to_string (const T& t)
               ^~~~~~~~~
binacpp_utils.h:36:20: note: candidate: std::__cxx11::string to_string(double)
 static std::string to_string(double val)
                    ^~~~~~~~~
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from binacpp.h:19,
                 from binacpp.cpp:14:
/usr/include/c++/6/bits/basic_string.h:5522:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5513:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5504:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5498:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5492:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5486:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5481:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5475:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5470:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
binacpp.cpp:921:42: error: call of overloaded ‘to_string(double&)’ is ambiguous
   post_data.append( to_string( stopPrice ) );
                                          ^
In file included from binacpp.cpp:16:0:
binacpp_utils.h:28:15: note: candidate: std::__cxx11::string to_string(const T&) [with T = double; std::__cxx11::string = std::__cxx11::basic_string<char>]
 inline string to_string (const T& t)
               ^~~~~~~~~
binacpp_utils.h:36:20: note: candidate: std::__cxx11::string to_string(double)
 static std::string to_string(double val)
                    ^~~~~~~~~
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from binacpp.h:19,
                 from binacpp.cpp:14:
/usr/include/c++/6/bits/basic_string.h:5522:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5513:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5504:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5498:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5492:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5486:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5481:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5475:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5470:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
binacpp.cpp:926:43: error: call of overloaded ‘to_string(double&)’ is ambiguous
   post_data.append( to_string( icebergQty ) );
                                           ^
In file included from binacpp.cpp:16:0:
binacpp_utils.h:28:15: note: candidate: std::__cxx11::string to_string(const T&) [with T = double; std::__cxx11::string = std::__cxx11::basic_string<char>]
 inline string to_string (const T& t)
               ^~~~~~~~~
binacpp_utils.h:36:20: note: candidate: std::__cxx11::string to_string(double)
 static std::string to_string(double val)
                    ^~~~~~~~~
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from binacpp.h:19,
                 from binacpp.cpp:14:
/usr/include/c++/6/bits/basic_string.h:5522:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5513:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5504:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5498:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5492:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5486:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5481:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5475:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5470:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
binacpp.cpp: In static member function ‘static void BinaCPP::withdraw(const char*, const char*, const char*, double, const char*, long int, Json::Value&)’:
binacpp.cpp:1384:38: error: call of overloaded ‘to_string(double&)’ is ambiguous
  post_data.append( to_string( amount ));
                                      ^
In file included from binacpp.cpp:16:0:
binacpp_utils.h:28:15: note: candidate: std::__cxx11::string to_string(const T&) [with T = double; std::__cxx11::string = std::__cxx11::basic_string<char>]
 inline string to_string (const T& t)
               ^~~~~~~~~
binacpp_utils.h:36:20: note: candidate: std::__cxx11::string to_string(double)
 static std::string to_string(double val)
                    ^~~~~~~~~
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from binacpp.h:19,
                 from binacpp.cpp:14:
/usr/include/c++/6/bits/basic_string.h:5522:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5513:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5504:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5498:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5492:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5486:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5481:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5475:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/6/bits/basic_string.h:5470:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
Makefile:38: recipe for target '../lib/libbinacpp/lib/binacpp.o' failed
make: *** [../lib/libbinacpp/lib/binacpp.o] Error 1

Now the error list is longer but i tried to capture the First and the last part of the terminal errors.

I tried to patch it with the following code:

#include <string>   
#include <sstream>

namespace patch
{ 
    template < typename T > std::string to_string( const T& n )
    {   
        std::ostringstream stm ;
        stm<<n ;
        return stm.str() ;

    }
}

I read in another question that this would solve the problem when replacing every

 to_string()

with

patch::to_string()

i tried it and the result is exacly the same (well actually the screenshots are from after the editing)

The API i want to use can be downloaded here: https://github.com/binance-exchange/binacpp

Like i said i am using an raspberry pi with rasbian.

and codeblocks.

Thanks in advance AD

1 Answers1

2

As the error message says, the problem is that the call is ambiguous. It wouldn't be, except the binacpp_utils.h file contains its own to_string template in the global scope, and has a using namespace std statement. These are both big bad mistakes that have broken the build on a C++11 toolchain.

You should raise an issue with the library's developer.

In the meantime, the global namespace is ruined but you can still refer to std::to_string explicitly in your own code.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055