tensorflow: TensorFlow 2.10.0 build for C++ using Bazel failed with error "Link.exe 1120 failed: error executing command " in Windows 10

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.10.0

Custom code

No

OS platform and distribution

Windows 10 Pro

Mobile device

Windows 10 Pro

Python version

3.9.13

Bazel version

5.1.1

GCC/compiler version

No response

CUDA/cuDNN version

11.2/8.1

GPU model and memory

No response

Current behavior?

Steps followed:

  1. Installed Bazel version 5.1.1 and set the environment variables.
  2. Installed msys2 and set the environment variables.
  3. Installed visual studio professional 2019 for C++ build .
  4. Installed python 3.9.13
  5. Installed python dependencies like numpy, wheel, keras
  6. Downloaded tensorflow 2.10.0 source from tensorflow github repository
  7. Configured TensorFlow with default configuration using ‘./configure’
  8. Build TensorFlow using the command ‘bazel --host_jvm_args=-Xmx4g --output_base=D:\0 build --jvmopt=“-server -Xms2g” --config=opt tensorflow:tensorflow_cc’

While tried to build ‘tensorflow_cc’ with the above command, the compilation is success but the linking failed with error 1120.

The following versions of tools are used for building: Tensorflow - 2.10.0 Python - 3.9.13 Visual studio - Professional 2019 Bazel - 5.1.1 MSYS - 2 Tried the GPU build with ‘Cuda 11.2 and Cudnn 8.1’ also but the result is same.

Note: Earlier tried to build tensorflow.dll (not tensorflow_cc), for which the compilation and linking was success and tensorflow.dll got generated. But while linking the tensorflow.dll to visual studio cpp project, I got ‘unresolved external symbol errors’. It seems the dll generated by this method has the ‘C’ symbols instead of ‘CPP’ symbols in it.

Standalone code to reproduce the issue

Tensorflow source from github and tried to build from windows for c++.

Relevant log output

Getting link errors

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 30 (4 by maintainers)

Most upvoted comments

@ajithrp123 thanks for reply. build is succesfully completede with 3.8.0. but get unresolved external error with ms visual stdio C++ desktop when build it windwos 10.

added additional dependencies (bazel build --config=opt //tensorflow:tensorflow.lib) tensorflow.lib tensorflow_cc.lib include directory (bazel build --config=opt //tensorflow:install_headers) …/include …/include/src

ms visul stdio configuration is release and platform is x64.

Actullay my target is compiling saved_model_bundle_test.cc (tensorflow/cc/saved_model ) but I can not do it on windows 10. then I will adapt my project.

Can you give me suggestion? thanks.

@hidon Is this link error. Link error is expected one because not all the symbols exported to tensorflow_cc.dll. We need to manually export (using TF_EXPORT) needed symbols to dll. Please look into the following tutorial for reference https://medium.com/vitrox-publication/deep-learning-frameworks-tensorflow-build-from-source-on-windows-python-c-cpu-gpu-d3aa4d0772d8

@ajithrp123

@shangerxin thanks for the update , looking forward for your solution One doubt, Is it possible to build tensorflow_cc.dll in windows for tf2.10.0 or is there any bug in the build setup?

@ajithrp123 Yes it is supported. I can see the target tensorflow_cc from the file

tensorflow\BUILD

tf_cc_shared_library(
    name = "tensorflow_cc",
    additional_linker_inputs = [
        "//tensorflow:tf_exported_symbols.lds",
        "//tensorflow:tf_private_symbols.lds",
        "//tensorflow:tf_version_script.lds",
    ],
...

I’m still investigating the why there are so many link errors. Wil update the result later. Thanks.

I have double confirmed with the Team. The target tensorflow_cc is not support Windows platform. You can check these files:

https://github.com/tensorflow/tensorflow/blob/3d79c0e4a663a4dd846c38cb5cdc0beeb3292d83/tensorflow/python/BUILD#L630-L640 https://github.com/tensorflow/tensorflow/blob/1dbc8d1b0126dcac5edea9a65a1fddbfe5e337ce/tensorflow/compiler/mlir/lite/experimental/tac/py_wrapper/BUILD#L37-L41

The Windows platform has no dependency files.

Hi @ajithrp123, got it, thank you, could you please share the steps you are following and the errors you are getting while running TF 2.10.0? No WSL is not needed for TF 2.10.0