Folk,Bazel Link .so庫位於完全不同的,非常遠程的文件夾中
我想鏈接.h和靜態庫到我的tensorflow程序中。我的頭是在
/usr/local/include/lcm
而且靜態/共享庫(.so等)
/usr/local/lib
但是巴澤爾抱怨他們不存在,或者說,它無法找到他們。這是我對我的BUILD文件代碼:
package(default_visibility = ["//tensorflow:internal"])
licenses(["notice"]) # Apache 2.0
exports_files(["LICENSE"])
# LCM shared libraries path
cc_library(
name = "lcm_lib",
srcs = glob([
"*.so",
]),
copts = ["-L/usr/local/lib"],
linkopts = ["-pthread", "-shared"],
visibility = ["//visibility:public"],
)
# LCM header libraries path
cc_library(
name = "lcm_headers",
hdrs = glob([
"include/**/*.h",
]),
copts = ["-L/usr/local/include"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
cc_binary(
name = "myProject",
srcs = [
"main.cc",
],
linkopts = ["-lm"],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/core:framework_internal",
"//tensorflow/core:tensorflow",
],
)
filegroup(
name = "all_files",
srcs = glob(
["**/*"],
exclude = [
"**/METADATA",
"**/OWNERS",
"bin/**",
"gen/**",
],
),
visibility = ["//tensorflow:__subpackages__"],
)
如果我刪除LCM相關的代碼(來自BUILD和main.cc),然後我的程序生成並運行。當我包含LCM時,那麼我得到錯誤說lcm :: LCM ::〜LCM()是未定義的,並且它找不到liblcm.so。 現在,我的非張量流代碼(或者我的大部分項目)正在運行cmake,可以找到LCM和我需要的其他庫(openCV等)。我在我的CMakeList.txt中使用如下命令:
# search path for LCM header files
set(LCM_IncludeSearchPaths
/usr/include/
/usr/local/include/
/opt/local/include
)
# search path for LCM static/dynamic libraries
set(LCM_LibrarySearchPaths
/usr/lib/
/usr/local/lib/
/opt/local/lib/
)
find_path(LCM_INCLUDE_DIR
NAMES lcm/lcm.h
HINTS ${LCM_IncludeSearchPaths}
)
FIND_LIBRARY(LCM_LIBS
NAMES lcm
HINTS ${LCM_LibrarySearchPaths}
PATH_SUFFIXES lib
)
這一切都有效。但它並不適用於tensorflow和巴澤爾工作
很抱歉的長期問題:-(
我得到的錯誤: ERROR:/ home/mario/tensorflow_HY/tensorflow/tensorflow/examples/MYPROJECT/cpp/BUILD:39:1:沒有這樣的軟件包'@ lcm_headers //':加載軟件包'external'時出錯:名爲'lcm_headers'的軟件庫無法由'// tensorflow/examples/MYPROJECT/cpp:PROJECT'來解決和引用。 – Pototo
參見上面的我的WOKSPACE和新的BUILD文件。在此先感謝您的幫助 – Pototo
是否將工作區文件粘貼到回購的根目錄中?也許你有兩個工作區文件,一個在根目錄中,一個在tensorflow/examples/MYPROJECT /中。嘗試編輯根目錄。除此之外,它看起來確定.. – mhlopko