How to build opt so with symbols (--strip=never)

I can bulid a “dbg” so with symbols by:
bazel build -c dbg --strip=never --cxxopt=–std=c++11 --config=android_arm //tensorflow/lite/c:tensorflowlite_c

but when I change “-c dbg” to " -c opt --copt=‘-g’ " , libtensorflowlite_c.so without symbols.
(bazel build -c opt --copt=‘-g’ --strip=never --cxxopt=–std=c++11 --config=android_arm //tensorflow/lite/c:tensorflowlite_c)

How can I get an opt so with symbols ?
(tensorflow 2.2, bazel 2.0)

Thank you very much.

Hi @user22_1 ,

To build an optimized TensorFlow Lite C++ shared object (libtensorflowlite_c.so) with symbols using Bazel, use the following command:

bazel build -c opt --copt='-g' --strip=never --cxxopt=--std=c++11 --config=android_arm //tensorflow/lite/c:tensorflowlite_c 

This command retains symbols in the optimized build by combining --copt=‘-g’ (for debugging symbols) with --strip=never (to prevent symbol stripping). Additionally, ensure that both --copt and --cxxopt are set correctly. Verify symbols with nm or readelf. If symbols are missing, check for TensorFlow-specific stripping rules in the build scripts .

Hope this helps ,

Thank You .