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;
}