'clang linker error when compiling simple C program on OS X
I was building this code from this article
I was using the recommended command to build it: gcc -Wall -o keyboard_leds keyboard_leds.c -framework IOKit -framework CoreFoundation
$ curl -O http://osxbook.com/book/bonus/chapter10/kbdleds/download/keyboard_leds.c
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11542 100 11542 0 0 139k 0 --:--:-- --:--:-- --:--:-- 140k
$ clang -Wall -o keyboard_leds keyboard_leds.c -framework IOKit -framework CoreFoundation
Undefined symbols for architecture x86_64:
"_print_errmsg_if_err", referenced from:
_create_hid_interface in keyboard_leds-d14ed5.o
"_print_errmsg_if_io_err", referenced from:
_create_hid_interface in keyboard_leds-d14ed5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$
The code is very straightforward, if a little dated (6 years). I cannot see any mention anywhere of the symbols that begin with the underscore. I'm probably missing something simple, but I'm completely stumped about where these symbols come from.
What gives? I can comment out the calls to get it to compile.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|