- 我的代码
EPollPoller::EPollPoller(EventLoop *loop)
: Poller(loop)
, epollfd_(::epoll_create1(EPOLL_CLOEXEC))
, events_(kInitEventListSize)
{
if (epollfd_ < 0)
{
LOG_FATAL("epoll create error:%d\n", errno);
}
}
class Poller : noncopyable
{
public:
using ChannelList = std::vector<Channel *>;
Poller(EventLoop *loop);
virtual ~Poller() ;
}
- 具体报错
/usr/bin/ld: CMakeFiles/muduoTest.dir/Poller.o: warning: relocation against
_ZTV6Poller' in read-only section
.text’
/usr/bin/ld: CMakeFiles/muduoTest.dir/EPollPoller.o: in functionEPollPoller::EPollPoller(EventLoop*)': /home/jok/01wyc-work/01share/01moduo/muduolib/EPollPoller.cc:25: undefined reference to
Poller::~Poller()’
/usr/bin/ld: CMakeFiles/muduoTest.dir/EPollPoller.o: in function `EPollPoller::~EPollPoller()':
- 解决办法
在虚函数的声明处,加上{}
virtual ~Poller() ;
改为
virtual ~Poller() {};