Reputation: 13289
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?
Upvotes: 1
Views: 978
Reputation: 23796
As stated here, you have to link it with -lgearman
gcc test.c -lgearman
Upvotes: 0
Reputation: 321
maybe your need to define the "include path" and the "lib path", for example, the head file "libgearman/gearman.h" in the /usr/local, the library libgearman.so in the /usr/local/libgearman/lib
the compile command like, gcc -I/usr/local -L/usr/local/libgearman/lib test.c -lgearman
Upvotes: 3
Reputation: 1370
maybe your need to define the lib path, like
-L/usr/lib/
, use your libgearman.a stored path to substitute -L/usr/lib/
Upvotes: 3