[問題] c++ hash_map問題
開發平台(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好像不會這樣
麻煩幫解答了 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.207.98
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1401199231.A.DCB.html
※ 編輯: kasa246 (140.113.207.98), 05/27/2014 22:37:52
→
05/27 22:55, , 1F
05/27 22:55, 1F
→
05/27 23:08, , 2F
05/27 23:08, 2F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章