- 论坛徽章:
- 0
|
10可用积分
先贴代码class CIMtext:public CProtocol,public CMISC
{
public:
CIMtext(CSock *sock):CProtocol(sock),CMISC()
{
counter = 0;
}
~CIMtext()
{}
static bool MatchProtocol(CSock *sock);
int Parse(void);
private:
static vector<IMKeyVal *>::iterator it; //关键字索引
unsigned int counter; //记录该对象已经Pare的次数,超过一定数值将。
bool MatchSendFlag(IdxKeeper *idk,string &data);
bool MatchRecvFlag(IdxKeeper *idk,string &data);
bool MatchLoginFlag(IdxKeeper *idk,string &data);
bool MatchTryLoginFlag(IdxKeeper *idk,string &data);
bool MatchLogoutFlag(IdxKeeper *idk,string &data);
bool MatchSwitchFlag(IdxKeeper *idk,string &data);
bool GetSendInfo(IdxKeeper *idk,string &data);
bool GetRecvInfo(IdxKeeper *idk,string &data);
bool GetLoginInfo(IdxKeeper *idk,string &data);
bool GetTryLoginInfo(IdxKeeper *idk,string &data);
bool GetLogoutInfo(IdxKeeper *idk,string &data);
bool GetSwitchInfo(IdxKeeper *idk,string &data);
bool NeedDrop(void);
}; |
如上类 CIMtext继承CProtocol和CMISC,构造函数明确的给出了。
我把该代码编译成so库,在别的代码动态打开so库。编译参数为g++ -shared -o libcap.so xxxxxxxx
编译过程没有问题。
但是运行时dlopen报错: dlopen() error: ./libcap.so: undefined symbol: _ZN7CIMtext2itE
nm libcap.so后输出的相关信息为:# nm libcap.so |grep CIMtext
0004c916 t _GLOBAL__I__ZN7CIMtext13MatchProtocolEP5CSock
0004bd70 T _ZN7CIMtext11GetRecvInfoEP9IdxKeeperRSs
0004ba28 T _ZN7CIMtext11GetSendInfoEP9IdxKeeperRSs
0004c0b8 T _ZN7CIMtext12GetLoginInfoEP9IdxKeeperRSs
0004c448 T _ZN7CIMtext13GetLogoutInfoEP9IdxKeeperRSs
0004c670 T _ZN7CIMtext13GetSwitchInfoEP9IdxKeeperRSs
0004a8e8 T _ZN7CIMtext13MatchProtocolEP5CSock
0004b6d8 T _ZN7CIMtext13MatchRecvFlagEP9IdxKeeperRSs
0004b598 T _ZN7CIMtext13MatchSendFlagEP9IdxKeeperRSs
0004b818 T _ZN7CIMtext14MatchLoginFlagEP9IdxKeeperRSs
0004c320 T _ZN7CIMtext15GetTryLoginInfoEP9IdxKeeperRSs
0004b920 T _ZN7CIMtext15MatchLogoutFlagEP9IdxKeeperRSs
0004b9a4 T _ZN7CIMtext15MatchSwitchFlagEP9IdxKeeperRSs
0004b89c T _ZN7CIMtext17MatchTryLoginFlagEP9IdxKeeperRSs
U _ZN7CIMtext2itE
0004b04a T _ZN7CIMtext5ParseEv
0004b54a T _ZN7CIMtext8NeedDropEv
0003eadc W _ZN7CIMtextC1EP5CSock
0004cc7c W _ZN7CIMtextD0Ev
0004cc2e W _ZN7CIMtextD1Ev
00093a60 V _ZTI7CIMtext
00071eb8 V _ZTS7CIMtext
00093a38 V _ZTV7CIMtext[/code] |
问题是:
1 红色部分应当不是构造函数的smbol,那它是什么?
2 是不是CIMtext类中的static成员it引起的这种问题?因为从 _ZN7CIMtext2itE看应该是个CIMtext(it) 样子的函数. |
最佳答案
查看完整内容
static vector::iterator it; 没有定义一般类似struct foo{ static TYPE bar;};在 .cpp 文件要定义barTYPE foo::bar = ...;
|