简体   繁体   中英

Compiling and linking libev on Mac OS X

Yet another symbol(s) not found issue with Mac OS X. I wrote a C program that uses the libev event loop library that when compiled produces this output:

$ make
clang midnight.c midnight_logging.c -o midnight
Undefined symbols for architecture x86_64:
  "_ev_default_loop", referenced from:
      _main in midnight-Wlcawk.o
  "_ev_io_start", referenced from:
      _main in midnight-Wlcawk.o
  "_ev_run", referenced from:
      _main in midnight-Wlcawk.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [midnight] Error 1

I used homebrew to install libev. The shared library is in /usr/local/lib per normal and I've used every combination of compiler arguments including "-I /usr/local/lib", "-l libev" and "-L /usr/local/lib".

Assistance appreciated, I'd rather not have to statically compile.

But you do not link against libev! The compiler isn't a clairvoyant (nor is the linker), you have to tell it what to search for those symbols...

clang midnight.c midnight_logging.c -o midnight -lev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM