I've compiled a binary (my_test.o) and am trying to link it against a library provided by a manufacturer (libmfghost.so.2).
The manufacturer has provided example code and an example makefile, which works to compile examples and link them with the library. I started by copying the flags but at this point I am directly referencing their rules.mk in my Makefile, to ensure I have the exact same compile and link flags.
When I try to link, I get "undefined reference to mfg_device_init()". The linker can't find the reference, however:
- If I typo the
-lmfghost
, it gives an error that it can't find the other library, so with it written correctly, it clearly is finding the library - If I typo the name of the function call, the compile fails, as the function isn't in the header. I'm certain I have the prototype matched
nm libmfghost.so.2 | grep device_init
shows that the symbol is in the shared object.
Minimal example that reproduces this:
clang++ -o my_test -lmfghost -L../sdk/builds/debug/lib my_test.o
Why can't ld find the function in a library that it clearly sees and clearly has the function in it?