我正在使用binance cpp api开发一个软件。
现在我遇到的问题是,在我的raspian和安装的代码块上,我无法使用提供的预编译.so库来存储binacpp。
所以我读到我需要为我的系统编译它并尝试运行make via terminal现在发生这种情况:
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
现在错误列表更长,但我试图捕获终端错误的第一部分和最后一部分。
我尝试使用以下代码修补它:
#include <string>
#include <sstream>
namespace patch
{
template < typename T > std::string to_string( const T& n )
{
std::ostringstream stm ;
stm<<n ;
return stm.str() ;
}
}
我在另一个问题中读到,这可以在更换每个
时解决问题 to_string()
与
patch::to_string()
我尝试了,结果非常相似(实际上截图来自编辑后)
我想要使用的API可以在这里下载:https://github.com/binance-exchange/binacpp
就像我说我正在使用覆盆子pi和rasbian。
和codeblocks。
先谢谢AD
答案 0 :(得分:2)
正如错误消息所示,问题是呼叫不明确。除了the binacpp_utils.h file在全局范围内包含自己的to_string
模板,和具有using namespace std
语句之外,它不可能。这些都是重大错误,已经打破了C ++ 11工具链的构建。
您应该向图书馆的开发者提出问题。
与此同时,全局命名空间已被破坏,但您仍然可以在自己的代码中明确引用std::to_string
。