[問題] 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