我正在處理一個(C++)程序,它必須處理大量與文件/目錄相關的信息(或多或少我有一個路徑作爲關鍵字)。目前我已經嘗試使用哈希表實現。考慮到數據量,這看起來工作得很好,但在分析後我發現它們仍然是系統中最慢的一個環節,所以爲了改進,我研究了使用Trie。鏈接錯誤,儘管一切都存在
我發現以下(C實現)http://linux.thai.net/~thep/datrie/datrie.html並閱讀文檔,它似乎是一個相當不錯的。然而,在試圖編寫一個簡單的測試片段時,我最終會遇到一個奇怪的鏈接錯誤。
奇怪的是:有問題的函數存在(如在其中,在cpp文件中)並且創建了對象文件,那麼爲什麼會出現鏈接錯誤?
我的代碼:
#include <iostream>
#include <datrie/trie.h>
extern int main(int, char**)
{
// create character map covering unicode characters
AlphaMap *map = alpha_map_new();
AlphaChar start = 32, end = 1114111;
alpha_map_add_range(map, start, end);
// create a trie and test it
Trie *test = trie_new(map);
const AlphaChar key[] = {0x64,0x64,0x64,0x64};
trie_store(test, key, 3);
TrieData *data;
trie_retrieve(test, key, data);
std::cout << *data << std::endl;
return 0;
}
錯誤(簡體和行包好可讀性)
main.obj : error LNK2001: unresolved external symbol
"int __cdecl alpha_map_add_range(struct _AlphaMap *,unsigned int,unsigned int)"
main.obj : error LNK2001: unresolved external symbol
"struct _AlphaMap * __cdecl alpha_map_new(void)"
使用Visual Studio 2010
啊,IC。謝謝!現在工作。 – srcspider 2010-11-09 00:40:07