$ apt-cache show libgmp10
Package: libgmp10
...
Version: 2:5.0.2+dfsg-2ubuntu2
测试.cpp:
#include <gmpxx.h>
#include <iostream>
using namespace std;
int main()
{
mpz_class x = 42;
cout << x;
}
编译:
$ g++ -c test.cpp -o test.o
$
好的
关联:
$ g++ test.o -lgmp
test.o: In function `std::ostream& operator<<
<__mpz_struct [1]>(std::ostream&,
__gmp_expr<__mpz_struct [1],
__mpz_struct [1]> const&)':
test.cpp:(.text._ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E[_ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E]+0x2a):
undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
collect2: error: ld returned 1 exit status
它在链接时找不到operator<<(ostream&, mpz_class)
。是什么赋予了?