我正在尝试在 Xcode 4.0.2 的演示 C++ 项目中使用 GMP 5.0.2 库,但无法使链接正常工作。
我查看了 StackOverflow 帖子中的评论:在 Xcode 中添加链接器标志,在 /usr/local/lib 和 /usr/local/include 中找到了 GMP 库和头文件,并将它们拖到项目目标中。这允许项目编译,但显然不能链接。我得到的错误是
Undefined symbols for architecture x86_64:
"operator>>(std::istream&, __mpz_struct*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
关于我接下来应该尝试什么的任何建议?谢谢。
#include <iostream>
#include "gmp.h"
#include <stdio.h>
using namespace std;
int main (int argc, const char * argv[])
{
mpz_t x;
mpz_init(x);
cin >> x;
cout << "x = " << endl;
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}