I am trying to compile a simple gearman worker on C. I use mac. Here is the code:
#include <libgearman/gearman.h>
int main(void) {
gearman_worker_st worker;
gearman_worker_create(&worker);
gearman_worker_add_server(&worker, "localhost", 4730);
return 0;
}
When I try to compile it with:
#gcc test.c Undefined symbols for architecture x86_64: "_gearman_worker_add_server", referenced from: _main in ccLUuf8y.o "_gearman_worker_create", referenced from: _main in ccLUuf8y.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status
I know I have to link gcc with gearman but when try:
#gcc test.c -lgearman ld: library not found for -lgearman collect2: ld returned 1 exit status
Any ideas?
maybe your need to define the lib path, like
-L/usr/lib/
, use your libgearman.a stored path to substitute -L/usr/lib/