1

I am getting a linker error of library not found on mac os (M1) despite specifying the -L flag.

I tried all combination of library name: with/without .so suffix, using -lname and using -l:name

Here is the command:

$ clang++ -std=c++11  -fPIC \
  -I/opt/homebrew/Caskroom/miniforge/base/envs/tfconda/lib/python3.10/site-packages/tensorflow/include \
  -L/opt/homebrew/Caskroom/miniforge/base/envs/tfconda/lib/python3.10/site-packages/tensorflow/python/ \
  -l:_pywrap_tensorflow_internal.so \
  -shared -O2 \
  -o plugin.so ppu_pluggable_device.cc
1 warning generated.
ld: library not found for -l:_pywrap_tensorflow_internal.so
clang: error: linker command failed with exit code 1 (use -v to see invocation)

A simple ls to prove the library is there:

$ ls /opt/homebrew/Caskroom/miniforge/base/envs/tfconda/lib/python3.10/site-packages/tensorflow/python
__init__.py             compat                  kernel_tests                saved_model
__pycache__             compiler                layers                  summary
_pywrap_mlir.so             data                    lib                 tf2.py
_pywrap_parallel_device.so      debug                   module                  tools
_pywrap_py_exception_registry.so    distribute              ops                 tpu
_pywrap_quantize_training.so        dlpack                  platform                training
_pywrap_sanitizers.so           eager                   profiler                types
_pywrap_tensorflow_internal.so      estimator               pywrap_mlir.py              user_ops
_pywrap_tfe.so              feature_column              pywrap_sanitizers.py            util
_pywrap_toco_api.so         framework               pywrap_tensorflow.py
autograph               grappler                pywrap_tensorflow_internal.py
client                  keras                   pywrap_tfe.py

I should mention that I am new to development on mac os, I am used to developping on linux.

Edit: I tried doing the exact same thing on a linux virtual machine (on a windows desktop) and it worked without issues, so this really seems to come from the mac configuration/environment. I don't know why it is not finding the library with the given arguments.

slai-nick
  • 95
  • 1
  • 7
  • I specified that I have tried without the semicolon as well (included in "all combinations'). It seems that without semicolon it is adding a "lib" prefix ([source](https://stackoverflow.com/questions/28219849/how-to-get-clang-to-link-against-a-library-without-the-lib-prefix)). I really believe that it is not a command format issue after having tried all combinations. – slai-nick Mar 07 '22 at 17:48
  • what output do you get if you run the command with `-v`? – TallChuck Mar 11 '22 at 00:18

0 Answers0