This is the error I get
Undefined symbols:
"Config::fmap", referenced from:
register_function(unsigned int (*)(unsigned int))in Config.o
print_config() in shared.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Config.h
#include <map>
#include <boost/preprocessor/stringize.hpp>
typedef unsigned int (*fptr_t)(unsigned int);
typedef std::map<fptr_t, std::string> function_name_map_type;
void register_hash_names();
void register_function(fptr_t funct_pointer);
class Config
{
public:
static function_name_map_type fmap;
};
Config.cpp
function_map_t fmap;
void register开发者_如何学C_hash_names()
{
register_function(sha1);
...
}
void register_function(fptr_t funct_pointer)
{
(Config::fmap)[funct_pointer] = BOOST_PP_STRINGIZE(funct_pointer);
}
Shared.cpp where the error originates from:
std::cout << "\t " << Config::fmap[Config::current_hash_function] << "\n";
The definition in the .cpp should be:
function_map_t Config::fmap;
精彩评论