0
我有此示例代碼:未定義參照MONGO :: curTimeMillis64()
#include <iostream>
#include <mongo/util/time_support.h>
using namespace std;
int main()
{
cout << mongo::curTimeMillis64() << endl;
return 0;
}
和與編譯:
g++ -I/tmp/include prova.cpp -o prova -L/tmp/lib -lmongoclient
結果是:
/tmp/ccH0vDvx.o: In function `main':
prova.cpp:(.text+0x5): undefined reference to `mongo::curTimeMillis64()'
collect2: error: ld returned 1 exit status
我使用mongo cxx驅動程序的26compat和我也與nm檢查庫內的符號:
nm /tmp/lib/libmongoclient.so | grep curTime
00000000000ea510 t _ZN5mongo13curTimeMicrosEv
00000000000ea4f0 t _ZN5mongo15curTimeMicros64Ev
00000000000ea440 t _ZN5mongo15curTimeMillis64Ev
一切似乎都沒問題,但編譯失敗。有什麼建議麼?
感謝