kja
kja

Reputation: 101

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.

Upvotes: 2

Views: 2914

Answers (1)

user529758
user529758

Reputation:

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

Upvotes: 4

Related Questions