I'm working on a (C++) program that has to process a lot of information associated with a file/directory (so more or less I have a path as a key). Currently I've attempted a implementation using hash tables. This seem to work reasonably well given the volume of data but after profiling I find they are still the slowest link in the system, so in order to improve I look into using a Trie.
I find the following (C implementation) http://linux.thai.net/~thep/datrie/datrie.html and reading into the documentation there it seems to be a fairly good. However in attempting to write a simple test snippet I end up with a strange link error.
The strange thing is: the function in question exists (as in its there, and in the cpp file) and the object files are created, so why is there a link error for it?
My code:
#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; } Error (simplified and line wrapped it for readability)
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)" Using Visual Studio 2010