Linker Errors while building tensorflow from source
I should mention that I am using my own toolchain, but is it essentially just clang. Code here: https://github.com/p3achyjr/p3achyGo/blob/main/toolchain/BUILD

I noticed that the generated CUDA toolchain file adds CUDA include paths, whereas I just add c/c++ include paths. Could this have something to do with it?

At any rate, is there a principled way to include tensorflow in a bazel project without building the entire thing statically every time? It's very hard to know which target to build just from perusing the source code (do I use `:tensorflow_cc`? `:tensorflow_framework`? Do I define my own `transitive_hdrs` rule?) @p3achyjr 
Sorry for the late reply, As per the documentation, TF v2.11.0 requires 8.1 cuDNN and 11.2 CUDA version.Could you please make sure to follow the instructions mentioned [here](https://www.tensorflow.org/install/source#linux) and check the [tested build configuration](https://www.tensorflow.org/install/source#gpu) as well. Please let us know if it helps?
Thank you! I tried using gcc 8 and gcc 9 today, and both failed. gcc8 gave the standard "lld undefined symbol". gcc failed much more catastrophically--It says the following command failed.

```
cd /home/axlui/.cache/bazel/_bazel_axlui/f4685961e4a033eb3c5c8f3ed28f41d5/execroot/__main__ &&   exec env -     CUDA_TOOLKIT_PATH=/usr/local/cuda-11.3     CUDNN_INSTALL_PATH=/usr/local/cuda     GCC_HOST_COMPILER_PATH=/usr/bin/x86_64-linux-gnu-gcc-8     LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nccl2/lib:/usr/local/cuda/extras/CUPTI/lib64     PATH=/home/axlui/.cache/bazelisk/downloads/bazelbuild/bazel-6.1.1-linux-x86_64/bin:/home/axlui/.local/bin:/usr/lib/llvm-12/bin:/home/axlui/.local/bin:/usr/local/cuda/bin:/opt/conda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin     PWD=/proc/self/cwd     PYTHONPATH=/home/axlui/p3achyGo/python:/usr/lib/llvm-12/bin:/home/axlui/.local/bin:/usr/local/cuda/bin:/opt/conda/bin:/opt/conda/condabin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin     PYTHON_BIN_PATH=/opt/conda/bin/python3     PYTHON_LIB_PATH=/bin     TF_CUDA_COMPUTE_CAPABILITIES=7.5     TF_CUDA_VERSION=11     TF_CUDNN_VERSION=8   external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc @bazel-out/k8-opt/bin/cc/main-2.params
```

When I run this by hand, it spits out tons of linker errors, such as:

```
/usr/bin/ld: mkl_nn_ops.cc:(.text.startup._Z41__static_initialization_and_destruction_0ii.constprop.218+0x731f): undefined reference to `tensorflow::shape_inference::BatchMatMulV2Shape(tensorflow::shape_inference::InferenceContext*)'
/usr/bin/ld: mkl_nn_ops.cc:(.text.startup._Z41__static_initialization_and_destruction_0ii.constprop.218+0x7372): undefined reference to `tensorflow::register_op::OpDefBuilderWrapper::operator()()'
/usr/bin/ld: mkl_nn_ops.cc:(.text.startup._Z41__static_initialization_and_destruction_0ii.constprop.218+0x7437): undefined reference to `tensorflow::register_op::OpDefBuilderWrapper::operator()()'
/usr/bin/ld: mkl_nn_ops.cc:(.text.startup._Z41__static_initialization_and_destruction_0ii.constprop.218+0x750c): undefined reference to `tensorflow::register_op::OpDefBuilderWrapper::operator()()'
```

Maybe you could take a look at how I've setup the build? I don't know if I'm using it right. https://github.com/p3achyjr/p3achyGo/blob/main/cc/nn/BUILD @p3achyjr ,

Could you please confirm are you using the TF standard Build instructions mentioned [here](https://www.tensorflow.org/install/source). Are you getting the error during `./configure` ?

Can you provide exact commands you have used to replicate the reported error ? This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60184">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60184">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

2.11

### Custom Code

Yes

### OS Platform and Distribution

Debian GNU/Linux 10

### Mobile device

_No response_

### Python version

3.7

### Bazel version

6.1.1

### GCC/Compiler version

LLVM 12

### CUDA/cuDNN version

11, 8

### GPU model and memory

T4

### Current Behaviour?

```shell
I'm trying to build tensorflow from source via the tutorial (using configure.py). However, when I do so, I run into linker errors, such as


ld.lld: error: undefined symbol: tensorflow::Tensor::Tensor()
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced 3 more times


I have tried running this multiple times, with both gcc/llvm, and via the config script/through a dependency in my project. When I build TF as a monolithic build, everything works fine, but when I try to build using the TF defaults, I always run into linker issues. What could be going on?
```


### Standalone code to reproduce the issue

```shell
git clone <tensorflow>
cd tensorflow
./configure
```


### Relevant log output

```shell
ld.lld: error: undefined symbol: tensorflow::Tensor::Tensor()
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced by nn_interface.cc
>>>               nn_interface.o:(nn::NNInterface::Infer(tensorflow::Scope&, tensorflow::ClientSession&)) in archive bazel-out/k8-opt/bin/cc/nn/libnn_interface.a
>>> referenced 3 more times
```
</details>