[问题] c++ hash_map问题

楼主: kasa246   2014-05-27 22:00:28
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
no
问题(Question):
使用hash_map时出现的run time error
错误结果(Wrong Output):
Can't open a dynamic library:
'A.so: cannot open shared object file: No such file or directory'
or
'.libs/A.so: undefined symbol:
std::tr1::hash<std::pair<unsigned int, unsigned short> >::operator()
(std::pair<unsigned int, unsigned short>) const'
程式码(Code):(请善用置底文网页, 记得排版)
部分程式码
主要目的要建立一个subnet和mask和port的hash_map
A.hh
#include <map>
typedef std::pair<uint32_t, uint16_t> SubnetMask;
typedef hash_map<SubnetMask, uint16_t> SubnetPort;
SubnetPort subnet_port;
A.cc
struct in_addr addr;
inet_aton("10.0.0.0", &addr);
uint16_t mask = 28;
uint16_t port = 80;
subnet_port.insert(pair<SubnetMask, uint16_t>(SubnetMask(addr.s_addr, mask)\
, port));
原本没错误
加了以上几行就会出现错误
所以makefile应该没问题吧?
是丢一个pair进去会有问题吗?
个别丢存成两个hash_map好像不会这样
麻烦帮解答了 谢谢
作者: azureblaze (AzureBlaze)   2014-05-27 22:55:00
楼主: kasa246   2014-05-27 23:08:00
感谢解答

Links booklink

Contact Us: admin [ a t ] ucptt.com