How to use libev in C Plus Plus

liukai at shinezone.com liukai at shinezone.com
Mon Jun 26 09:22:04 CEST 2017


#include "ev++.h"

#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>

ev::io io;

class MyClass
{
public:

  MyClass() {}

  ~MyClass() {}

public:

  void stdin_cb(ev::io &io, int revents)
  {
    puts("stdin ready");
    io.stop();
  }
};

int main(int argc, char *argv[])
{
  MyClass my_class;
  ev::dynamic_loop loop;

  io.set<MyClass, &MyClass::stdin_cb>(&my_class);
  io.set(0, EV_READ);
  //io.set(loop);

  //loop.run();

  return 0;
}

gcc -g -std=c++11 -L../libs -lev -Wl,-rpath,../libs -I../deps/libev test.cpp -o test

I got these error when I compiled this program. If you have free time please answer me why I got these error. Thank you...

/tmp/ccPE4ERN.o:在函数‘ev::bad_loop::bad_loop()’中:
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:121:对‘std::runtime_error::runtime_error(char const*)’未定义的引用
/tmp/ccPE4ERN.o:在函数‘ev::dynamic_loop::dynamic_loop(unsigned int)’中:
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:359:对‘__cxa_allocate_exception’未定义的引用
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:359:对‘__cxa_throw’未定义的引用
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:359:对‘__cxa_free_exception’未定义的引用
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:355:对‘__cxa_call_unexpected’未定义的引用
/tmp/ccPE4ERN.o:在函数‘ev::dynamic_loop::~dynamic_loop()’中:
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:362:对‘__cxa_call_unexpected’未定义的引用
/tmp/ccPE4ERN.o:(.rodata._ZTVN2ev8bad_loopE[_ZTVN2ev8bad_loopE]+0x20):对‘std::runtime_error::what() const’未定义的引用
/tmp/ccPE4ERN.o:在函数‘ev::bad_loop::~bad_loop()’中:
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:114:对‘std::runtime_error::~runtime_error()’未定义的引用
/tmp/ccPE4ERN.o:在函数‘ev::bad_loop::~bad_loop()’中:
/home/liukai2/legend_sdk/examples/../deps/libev/ev++.h:114:对‘operator delete(void*)’未定义的引用
/tmp/ccPE4ERN.o:(.rodata._ZTIN2ev8bad_loopE[_ZTIN2ev8bad_loopE]+0x0):对‘vtable for __cxxabiv1::__si_class_type_info’未定义的引用
/tmp/ccPE4ERN.o:(.rodata._ZTIN2ev8bad_loopE[_ZTIN2ev8bad_loopE]+0x10):对‘typeinfo for std::runtime_error’未定义的引用
/tmp/ccPE4ERN.o:(.eh_frame+0x8b):对‘__gxx_personality_v0’未定义的引用
collect2: error: ld returned 1 exit status



liukai at shinezone.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20170626/23aca61d/attachment.html>


More information about the libev mailing list