我安装了GCC
4.7.2和GMP
5.1.0,我在main.cpp
中编写了这个简单的代码,位于~/Desktop
:
#include <iostream>
#include <gmp.h>
using namespace std;
int main ()
{
mpz_t a;
mpz_init(a);
mpz_set_ui(a, 42);
cout << "Hello, world!" << endl;
}
我用以下代码编译它:
$ g++ main.cpp -o exe
但我收到此错误消息:
Undefined symbols for architecture x86_64:
"___gmpz_init", referenced from:
_main in ccC0FXun.o
"___gmpz_set_ui", referenced from:
_main in ccC0FXun.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
我认为这是因为它找不到GMP
库,我是对的吗?
那么如何在GMP
?
GCC