i use eclipse ide for c project on mac computer
i install usblib
sudo brew install libusb
and my program
#include <stdio.h>
#include <stdlib.h>
#include <libusb-1.0/libusb.h>
int main(void) {
libusb_context **libcontext;
int status = libusb_init(libcontext);
if (status == 0) {
printf("success");
}
}
when i build error
10:17:53 **** Build of configuration Debug for project testusb **** make all Building file: ../src/testusb.c Invoking: Cross GCC Compiler gcc -O0 -g3 -Wall -c -fmessage-length=0 -stdlib=libstdc++ -MMD -MP -MF"src/testusb.d" -MT"src/testusb.o" -o "src/testusb.o" "../src/testusb.c" ../src/testusb.c:16:6: warning: unused variable 'status' [-Wunused-variable] int status = libusb_init(libcontext); ^ ../src/testusb.c:16:27: warning: variable 'libcontext' is uninitialized when used here [-Wuninitialized] int status = libusb_init(libcontext); ^~~~~~~~~~ ../src/testusb.c:15:29: note: initialize the variable 'libcontext' to silence this warning libusb_context libcontext; ^ = NULL 2 warnings generated. Finished building: ../src/testusb.c Building target: testusb Invoking: Cross GCC Linker gcc -L/opt/local/lib -o "testusb" ./src/testusb.o Undefined symbols for architecture x86_64:
"_libusb_init", referenced from: _main in testusb.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: * [testusb] Error 1
how to fix that?