Repository: tensorflow
Issue: Can't compile Tensorflow 2.17 from source for cpu on fedora 40 : undefined reference
Labels: stat:awaiting tensorflower,type:build/install,comp:core,2.17


## I'm trying to compile Tensorflow 2.17 on a new fresh install of Fedora40 lxqt desktop (official spin).

#### what i've donne (all command as root):

 - Fresh Fedora install
 - dnf update
 - reboot
 - dnf install python3-devel g++ gcc cmake python3-pip git
   eigen3-devel
 - pip install -U --user pip
 - pip install -U  pip six numpy wheel setuptools mock
 - wget -O bazel
   https://github.com/bazelbuild/bazelisk/releases/download/v1.22.0/bazelisk-linux-amd64
 - mv bazel /bin/
 - chmod 555 /bin/bazel
 - git clone https://github.com/tensorflow/tensorflow.git
 - cd tensorflow
 - git checkout r2.17
 - export TF_PYTHON_VERSION=3.12
 - export LD_LIBRARY_PATH=/usr/local/lib
 - ./configure # <- answer default value but use GCC and say no to Cuda build, and
   used this optimisation flags: -march=native -mtune=native -O3
 - bazel build //tensorflow/tools/pip_package:wheel
   --repo_env=WHEEL_NAME=tensorflow_cpu --config=nonccl --config=opt --action_env="LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"

#### After a while a get this error:
```
ERROR: /home/brd/tensorflow/tensorflow/BUILD:1318:21: Linking tensorflow/libtensorflow_cc.so.2.17.1 failed: (Exit 1): gcc failed: error executing command (from target //tensorflow:libtensorflow_cc.so.2.17.1) /usr/bin/gcc @bazel-out/k8-opt/bin/tensorflow/libtensorflow_cc.so.2.17.1-2.params
/usr/bin/ld.gold: warning: bazel-out/k8-opt/bin/external/local_tsl/tsl/platform/cloud/_objs/gcs_file_system/gcs_file_system.pic.o: conflicting default version definition for _ZZZN3tsl17RamFileBlockCacheC4EmmmSt8functionIFN4absl12lts_202308026StatusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmmPcPmEEPNS_3EnvEENKUliPKcE0_clEiSK_E17vmodule_activated@@tensorflow
/usr/bin/ld.gold: bazel-out/k8-opt/bin/external/local_tsl/tsl/platform/cloud/_objs/gcs_file_system/gcs_file_system.pic.o: previous definition of _ZZZN3tsl17RamFileBlockCacheC4EmmmSt8functionIFN4absl12lts_202308026StatusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmmPcPmEEPNS_3EnvEENKUliPKcE0_clEiSK_E17vmodule_activated@@tensorflow here
bazel-out/k8-opt/bin/tensorflow/core/kernels/mkl/_objs/mkl_sparse_matrix_matmul_op/mkl_sparse_matrix_matmul_op.pic.o:mkl_sparse_matrix_matmul_op.cc:function tensorflow::register_kernel_0::{lambda(tensorflow::KernelDef const*)#1}::operator()(tensorflow::KernelDef const*) const::{lambda(tensorflow::OpKernelConstruction*)#1}::_FUN(tensorflow::OpKernelConstruction*):(.text._ZZNK10tensorflowL17register_kernel_0MUlPKNS_9KernelDefEE_clES3_ENUlPNS_20OpKernelConstructionEE_4_FUNES6_+0x18d): error: undefined reference to 'tensorflow::CSRMatMulOp<Eigen::ThreadPoolDevice, float>::CSRMatMulOp(tensorflow::OpKernelConstruction*)'
collect2: error: ld returned 1 exit status
Target //tensorflow/tools/pip_package:wheel failed to build
```
**how do i solve : undefined reference to 'tensorflow::CSRMatMulOp<Eigen::ThreadPoolDevice, float>::CSRMatMulOp(tensorflow::OpKernelConstruction\*)'?**

---
#### Version:
Fedora 40 lxqt desktop kernel 6.10.11-200.fc40.x86_64
(runing in virtualbox with: 8 cores and 23Gb of ram)

gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)

g++ (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)

Python 3.12.6

GNU Make 4.4.1

cmake version 3.28.2

Bazelisk version: v1.22.0
Build label: 6.5.0