假设我们有一个非常具体的GCC,我们想用它构建tensorflow
我们出口所需的东西:
export CC=/opt/gcc-4.9.3/bin/gcc
export CXX=/opt/gcc-4.9.3/bin/g++
export LIBRARY_PATH=/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/:$LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/:$LD_LIBRARY_PATH
bazel build //tensorflow:libtensorflow.so --action_env=LIBRARY_PATH --action_env=LD_LIBRARY_PATH
我们经营Bazel
bazel build //tensorflow:libtensorflow.so --action_env=LIBRARY_PATH --action_env=LD_LIBRARY_PATH --verbose_failures
WARNING: Output base '/home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1' is on NFS. This may lead to surprising failures and undetermined behavior.
WARNING: /home/xxx/tensorflow/tensorflow/core/BUILD:1787:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /home/xxx/tensorflow/tensorflow/tensorflow.bzl:1048:30.
INFO: Found 1 target...
ERROR: /home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1/external/nasm/BUILD.bazel:8:1: Linking of rule '@nasm//:nasm' failed (Exit 1): crosstool_wrapper_driver_is_not_gcc failed: error executing command
(cd /home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1/execroot/org_tensorflow && \
exec env - \
LD_LIBRARY_PATH=:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64 \
PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/var/cfengine/bin:/usr/local/cuda/bin:/home/xxx/.local/bin:/home/xxx/bin \
PWD=/proc/self/cwd \
external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -o bazel-out/host/bin/external/nasm/nasm -Wl,-no-as-needed -B/usr/bin/ -pie -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,--gc-sections -Wl,-S -Wl,@bazel-out/host/bin/external/nasm/nasm-2.params).
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
Target //tensorflow:libtensorflow.so failed to build
INFO: Elapsed time: 17.445s, Critical Path: 0.72s
然而,它无法检测到导出的-lgcc_s
和LIBRARY_PATH
中存在的LD_LIBRARY_PATH
。那么如何强制我们的LIBRARY_PATH
到我们的库所依赖的库上呢?
答案 0 :(得分:0)
执行--linkopt=-L/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/
之类的操作应该有效。