The libevent small example has been compiled and failed.

The following code is compiled through the brew installation libevent, on

mac, but it just doesn"t pass.

-sharpinclude <stdio.h>
-sharpinclude<event.h>
-sharpinclude<unistd.h>
-sharpinclude<event2/util.h>
int main(int argc, char const *argv[])
{
    struct event_base* base = event_base_new();
    return 0;
}

the error message is as follows:

Undefined symbols for architecture x86_64:
  "_event_base_new", referenced from:
  _main in main-d0e518.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v                                 
to see invocation)


Thank you!

Mar.23,2021

The libevent class library is missing from the

compile command. It should be like this

clang  xx.c  -levent
Menu