I'm tring to a fix a meson build not picking up on a link library. The meson.build file has
tz_dep = dependency(
'date',
default_options : [ 'use_system_tzdb=true' ],
fallback: [ 'date', 'tz_dep' ]
)
# ...
executable(
'waybar',
src_files,
dependencies: [
# ...
tz_dep
],
include_directories: [include_directories('include')],
install: true,
)
and it does find /usr/lib/x86_64-linux-gnu/cmake/date/dateConfig.cmake. The corresponding dateTargets-none.cmake is
#----------------------------------------------------------------
# Generated CMake target import file for configuration "None".
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "date::date-tz" for configuration "None"
set_property(TARGET date::date-tz APPEND PROPERTY IMPORTED_CONFIGURATIONS NONE)
set_target_properties(date::date-tz PROPERTIES
IMPORTED_LOCATION_NONE "${_IMPORT_PREFIX}/lib/x86_64-linux-gnu/libdate-tz.so.2.4.1"
IMPORTED_SONAME_NONE "libdate-tz.so.2.4.1"
)
list(APPEND _IMPORT_CHECK_TARGETS date::date-tz )
list(APPEND _IMPORT_CHECK_FILES_FOR_date::date-tz "${_IMPORT_PREFIX}/lib/x86_64-linux-gnu/libdate-tz.so.2.4.1" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
However, meson does not link /usr/lib/x86_64-linux-gnu/libdate-tz.so.2.4.1.
I'm not sure if the problem is in meson or the cmake config. I can provide more details if required.
i am wrinting an ebuild (gentoo package) for waybar right now and had the same issue you are describing. The solution is in your meson.build file, it specified the date dependency incomplete.
This is the patch i apply, and then it works (i have no clue about meson and stuff, but this seems makes waybar compile):
diff --git a/meson.build b/meson.build
index 5d45a29..dd56c29 100644
--- a/meson.build
+++ b/meson.build
## -98,7 +98,7 ## gtk_layer_shell = dependency('gtk-layer-shell-0',
required: get_option('gtk-layer-shell'),
fallback : ['gtk-layer-shell', 'gtk_layer_shell_dep'])
systemd = dependency('systemd', required: get_option('systemd'))
-tz_dep = dependency('date', default_options : [ 'use_system_tzdb=true' ], fallback: [ 'date', 'tz_dep' ])
+tz_dep = dependency('date', default_options : [ 'use_system_tzdb=true' ], modules : [ 'date::date', 'date::date-tz' ], fallback: [ 'date', 'tz_dep' ])
prefix = get_option('prefix')
sysconfdir = get_option('sysconfdir')
Maybe that helps!
Best Regards, Jonas
Related
my project A is relying on brpc:https://github.com/apache/incubator-brpc
projectA.WORKSPACE:
git_repository(
name = "brpc",
# remote = "https://github.com/apache/incubator-brpc.git",
remote = "git#github.com:apache/incubator-brpc.git",
commit = "c4de79975ea54684634d1e52d4691f96d134d34a",
shallow_since = "1671716289 +0800"
)
projectA.classB BUILD
load("#rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "client",
srcs = glob([
"*.cpp",
]),
hdrs = glob([
"*.h",
]),
deps = [ "#brpc//:brpc"
],
visibility = ["//visibility:public"],
)
thrid_party/brpc BUILD
load("#rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "brpc",
srcs = glob([
"src/brpc/*.cpp",
"src/bthread/*.cpp",
"src/brpc/*.h",
]),
deps = [
],
includes = [
".",
],
include_prefix = "brpc",
strip_include_prefix = "brpc",
visibility = ["//visibility:public"],
)
bazel build msg:
INFO: Invocation ID: 9aae1a04-1225-4f62-9780-d334df616f9a
WARNING: errors encountered while analyzing target '//client:client': it will not be built
INFO: Analysis succeeded for only 1 of 2 top-level targets
INFO: Analyzed 2 targets (19 packages loaded, 56 targets configured).
INFO: Found 1 target...
Target //third_party/brpc:brpc up-to-date (nothing to build)
ERROR: command succeeded, but not all targets were analyzed
INFO: Elapsed time: 0.262s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
FAILED: Build did NOT complete successfully
still can not find *.h in brpc
figure out which bazel config is wrong?
I assume the above issue because there might not be visibility of the header (.h) file to the sandbox and it gets fail. Try adding the files as mentioned here. Please reach if that did not resolve your issue.
I have created a Bazel project (C++) and have tried to include the gtkmm library in my project.
I get the below error, that header files are missing, e.g.:
Showing Recent Messages
../mediapipe/external/gtkmm/gtkmm/accelerator.cc:18:10: fatal error: 'glibmm/utility.h' file not found
#include <glibmm/utility.h>
^~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
Aspect #tulsi//:tulsi/tulsi_aspects.bzl%tulsi_outputs_aspect of //mediapipe/examples/motionize/motionize:motionize up-to-date:
bazel-bin/mediapipe/examples/motionize/motionize/motionize.tulsiouts
/private/var/tmp/_bazel_{user}/5a416b3c18d355cbf1dfbcf0102ffc0b/external/gtkmm/BUILD.bazel:7:11: Compiling gtkmm/accelerator.cc failed: (Aborted): wrapped_clang_pp failed: error executing command
Elapsed time: 10.459s, Critical Path: 0.45s
12 processes: 12 internal.
<*> Running Bazel completed in 10826.492 ms
Build did NOT complete successfully
The includes in the library do not seem to find the header files in general, not just this one. I have tried different setups and also a local repository instead of http_archive and I still get this kind of errors
Note: I am using Tulsi to create the Bazel xcode project
I have added the following in my WORKSPACE file:
http_archive(
name = "gtkmm",
strip_prefix = "gtkmm-4.8.0/gtk",
urls = ["https://github.com/GNOME/gtkmm/archive/refs/tags/4.8.0.zip"],
build_file = "#//third_party:gtkmm.BUILD",
)
I also added the gtkmm.BUILD file which looks like this:
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # BSD license
exports_files(["LICENSE"])
cc_library(
name = "main",
srcs = glob(
["**/*.cc"],
),
hdrs = glob([
"*.h",
"gtkmm/**/object_p.h",
"**/*.hg",
"**/*.h",
"**/selectiondata_private.h"
]),
includes = glob([
"*.h",
"gtkmm/**/object_p.h",
"**/*.hg",
"**/*.h",
"**/selectiondata_private.h"
]),
copts = ["-Iexternal/gtkmm-4.8.0/gtk"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
Finally my BUILD file:
cc_binary(
name="motionize",
srcs=["main.cpp"],
copts = [
"-Iexternal/gtkmm-4.8.0/gtk/gtkmm",
"-Iexternal/gtkmm-4.8.0/gtk/",
"-Iexternal/gtkmm-4.8.0/gtk/src",
"-Iexternal/gtkmm-4.8.0/gtk/gtkmm/private",
],
deps=[
"//mediapipe/framework:calculator_framework",
"//mediapipe/calculators/core:pass_through_calculator",
"//mediapipe/calculators/image:image_cropping_calculator",
"//mediapipe/calculators/image:scale_image_calculator",
"//mediapipe/framework/formats:image_frame",
"//mediapipe/framework/formats:image_frame_opencv",
"//mediapipe/framework/port:opencv_core",
"//mediapipe/framework/port:opencv_highgui",
"//mediapipe/framework/port:opencv_imgproc",
"//mediapipe/framework/port:opencv_imgcodecs",
"//mediapipe/framework/port:opencv_video",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:status",
"#gtkmm//:main",
],
)
I'm building for Android using selective registration and the //tensorflow/contrib/android:libtensorflow_inference.so target:
bazel build -c opt --copt="-DSELECTIVE_REGISTRATION" --copt="-DSUPPORT_SELECTIVE_REGISTRATION" //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --cpu=x86_64
Which works fine until I need to use an op that lives in contrib. Specifically I need access to ImageProjectiveTransform, which is part of the //tensorflow/contrib/image:image_ops_cc target. I tried modifying the //tensorflow/core:android_tensorflow_lib target to add it as a dependency:
# Full TensorFlow library with operator support. Use this unless reducing
# binary size (by packaging a reduced operator set) is a concern.
cc_library(
name = "android_tensorflow_lib",
srcs = if_android([":android_op_registrations_and_gradients"]),
copts = tf_copts(),
tags = [
"manual",
"notap",
],
visibility = ["//visibility:public"],
deps = [
":android_tensorflow_lib_lite",
":protos_all_cc_impl",
"//tensorflow/core/kernels:android_tensorflow_kernels",
"//tensorflow/contrib/image:image_ops_cc",
"//third_party/eigen3",
"#protobuf_archive//:protobuf",
],
alwayslink = 1,
)
But now the compile fails:
In file included from external/com_googlesource_code_re2/re2/bitstate.cc:25:
In file included from external/com_googlesource_code_re2/re2/prog.h:14:
In file included from external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/mutex:35:
external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
But if I specify C++11 in the bazel build call:
bazel build -c opt --copt="-std=c++11" --copt="-DSELECTIVE_REGISTRATION" --copt="-DSUPPORT_SELECTIVE_REGISTRATION" //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --cpu=x86_64
Then I get a different error:
ERROR: /private/var/tmp/_bazel_json/e38619818ff94aae50ac5b3bdbbe0f32/external/png_archive/BUILD:8:1: C++ compilation of rule '#png_archive//:png' failed (Exit 1)
error: invalid argument '-std=c++11' not allowed with 'C/ObjC'
Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
(I have no idea why anything in the Android build would be using Objective-C)
I also wanted to include ImageProjectiveTransform and encountered the same errors. I was able to successfully include it via the following steps, which are a modification of the procedure suggested here.
git clone https://github.com/tensorflow/tensorflow.git
git checkout r1.10
python tensorflow/tensorflow/python/tools/print_selective_registration_header.py --graphs PATH_TO_MODEL/model.pb > ops_to_register.h
cp ops_to_register.h tensorflow/tensorflow/core/framework/
cd tensorflow
bazel build -c opt --cxxopt="-DSELECTIVE_REGISTRATION" //tensorflow/contrib/android:libtensorflow_inference.so --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --jobs 10 --cxxopt=-std=c++11
cp bazel-bin/tensorflow/contrib/android/libtensorflow_inference.so ANDROID_PROJECT/libs/armeabi-v7a/
However, before running this, the following modifications were necessary.
These changes resolved compiling errors:
diff --git a/tensorflow/contrib/image/kernels/image_ops.h b/tensorflow/contrib/image/kernels/image_ops.h
index 209aa24..b8ec643 100644
--- a/tensorflow/contrib/image/kernels/image_ops.h
+++ b/tensorflow/contrib/image/kernels/image_ops.h
## -97,8 +97,8 ## class ProjectiveGenerator {
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T
nearest_interpolation(const DenseIndex batch, const float y, const float x,
const DenseIndex channel, const T fill_value) const {
- return read_with_fill_value(batch, DenseIndex(std::round(y)),
- DenseIndex(std::round(x)), channel, fill_value);
+ return read_with_fill_value(batch, DenseIndex(::round(y)),
+ DenseIndex(::round(x)), channel, fill_value);
}
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T
diff --git a/tensorflow/core/common_runtime/eager/BUILD b/tensorflow/core/common_runtime/eager/BUILD
index 7f28f3b..aa64220 100644
--- a/tensorflow/core/common_runtime/eager/BUILD
+++ b/tensorflow/core/common_runtime/eager/BUILD
## -150,7 +150,7 ## tf_cuda_library(
deps = select({
"//tensorflow:android": [
"//tensorflow/core:android_tensorflow_lib_lite",
- "//util/hash:farmhash_fingerprint",
+ #"//util/hash:farmhash_fingerprint",
],
"//conditions:default": [
"//tensorflow/core:core_cpu_lib",
## -223,7 +223,7 ## tf_cuda_library(
] + select({
"//tensorflow:android": [
"//tensorflow/core:android_tensorflow_lib_lite",
- "//util/hash:farmhash_fingerprint",
+ #"//util/hash:farmhash_fingerprint",
],
"//conditions:default": [
"//tensorflow/core:core_cpu",
This adds the files for missing ops and kernels to the build. For me, this included Asin, Sin, Cos, and ResizeArea in addition to ImageProjectiveTransform.
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 7599cf7..8ebb77e 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
## -4936,6 +4936,7 ## filegroup(
filegroup(
name = "android_extended_ops_headers",
srcs = [
+ "//tensorflow/contrib/image:image_ops_op_lib",
"argmax_op.h",
"avgpooling_op.h",
"batch_matmul_op_impl.h",
## -4995,6 +4996,11 ## filegroup(
filegroup(
name = "android_extended_ops_group1",
srcs = [
+ "//tensorflow/contrib/image:image_ops_kernels",
+ "resize_area_op.cc",
+ "cwise_op_asin.cc",
+ "cwise_op_cos.cc",
+ "cwise_op_sin.cc",
"argmax_op.cc",
"avgpooling_op.cc",
"batch_matmul_op_real.cc",
This causes tf.contrib to be registered before loading the frozen graph:
diff --git a/tensorflow/python/tools/print_selective_registration_header.py b/tensorflow/python/tools/print_selective_registration_header.py
index 21d7de0..923ad76 100644
--- a/tensorflow/python/tools/print_selective_registration_header.py
+++ b/tensorflow/python/tools/print_selective_registration_header.py
## -40,6 +40,8 ## import sys
from tensorflow.python.platform import app
from tensorflow.python.tools import selective_registration_header_lib
+from tensorflow import contrib
+contrib.resampler
FLAGS = None
This shows how to find the *.cc files with missing ops so they can be added to BUILD.
cd <tensorflow_repo>/tensorflow/core/kernels
for i in <op_list>
do
echo ====
echo $i
echo ====
grep -Rl \”$i\” .
done
I want to add a third-party C library to tensorflow so I can use it in one of the examples. There doesn't seem to be any examples to follow so any assistance would be appreciated.
Here's my work using event2 as the third-party C library.
I've created an 'ln -s' in tensorflow/third_party to provide the event2/ headers:
ls -al ~/code/tensorflow/third_party/event2
lrwxr-xr-x 1 XXXX staff 25 May 17 16:03 ~/code/tensorflow/third_party/event2 -> /usr/local/include/event2
/usr/local/include> ls event2
BUILD bufferevent_struct.h event_compat.h listener.h thread.h
buffer.h dns.h event_struct.h rpc.h util.h
buffer_compat.h dns_compat.h http.h rpc_compat.h visibility.h
bufferevent.h dns_struct.h http_compat.h rpc_struct.h
bufferevent_compat.h event-config.h http_struct.h tag.h
bufferevent_ssl.h event.h keyvalq_struct.h tag_compat.h
third_party/event2/BUILD:
licenses(["notice"])
cc_library(
name = "event2",
srcs = glob( [ "*.h" ] ),
visibility = [ "//visibility:public" ],
)
In tensorflow/examples/label_image/BUILD, I added the reference to libevent and my test files that use the events2 library:
cc_binary(
name = "label_image",
srcs = [
"main.cc",
"my_new_file_using_events.c",
"my_new_file_using_events.h",
],
linkopts = ["-lm", ],
copts = [ "-Ithird_party", ],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/core:framework_internal",
"//tensorflow/core:tensorflow",
"//third_party/event2:event2",
],
)
It compiles fine but when I run the binary I get the following errors:
dyld: lazy symbol binding failed: Symbol not found: _event_base_new
Referenced from: /Users/XXXX/code/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image
Expected in: flat namespace
dyld: Symbol not found: _event_base_new
Referenced from: /Users/XXXX/code/tensorflow/bazel-bin/tensorflow/examples/label_image/label_image
Expected in: flat namespace
[1] 41395 trace trap bazel-bin/tensorflow/examples/label_image/label_image
The libevent.a, libevent.dylib and other libevent* libs are in /usr/local/lib. according to nm, event_base undefined.
nm -f label_image | grep event_base
U _event_base_dispatch
U _event_base_new
How do I resolve this linkage error? Thanks.
Aren't we missing event2 sources there? Also, I think you want to put .h into hdrs attribute.
cc_library(
name = "event2",
hdrs = glob( [ "*.h" ] ),
srcs = glob( [ "*.cpp" ] ),
visibility = [ "//visibility:public" ],
)
Does this help?
I created a filegroup rule to have in one label all the .proto files of a library.
filegroup(
name = "protos_all_src",
srcs = glob(
["**/*.proto"],
exclude = [
"protobuf/worker.proto",
"protobuf/worker_service.proto",
"protobuf/master.proto",
"protobuf/master_service.proto",
],
)
)
tf_proto_library(
name = "protos_all",
srcs = ":protos_all_src",
),
...
)
but strangely with this format this other rule fails:
cc_library(
name = "lib_internal",
srcs = glob(
[
"lib/**/*.h",
"lib/**/*.cc",
"platform/*.h",
"platform/*.cc",
] + tf_additional_lib_srcs(),
exclude = [
"**/*test*",
"platform/**/cuda.h",
"platform/**/stream_executor.h",
],
),
hdrs = [
"lib/core/blocking_counter.h",
"lib/core/refcount.h",
"lib/gtl/edit_distance.h",
"lib/gtl/int_type.h",
"lib/gtl/iterator_range.h",
"lib/gtl/manual_constructor.h",
"lib/gtl/top_n.h",
"lib/io/iterator.h",
"lib/io/match.h",
"lib/jpeg/jpeg_handle.h",
"lib/png/png_io.h",
"lib/random/random.h",
"lib/random/random_distributions.h",
"lib/random/weighted_picker.h",
"lib/strings/ordered_code.h",
"lib/strings/proto_text_util.h",
"lib/strings/regexp.h",
"lib/strings/scanner.h",
"lib/wav/wav_io.h",
"platform/demangle.h",
"platform/denormal.h",
"platform/platform.h",
"platform/tensor_coding.h",
"platform/tracing.h",
],
copts = tf_copts(),
linkopts = ["-ldl"],
deps = [
":protos_all_cc",
"//tensorflow/core/platform/default/build_config:platformlib",
"//third_party/eigen3",
],
)
note the protos_all_cc rule as a dep.
if I revert back to
tf_proto_library(
name = "protos_all",
srcs = glob(
["**/*.proto"],
exclude = [
"protobuf/worker.proto",
"protobuf/worker_service.proto",
"protobuf/master.proto",
"protobuf/master_service.proto",
],
),
everything works fine.
I would expect that the first and the second format would be completely equal. What I am missing ?
EDIT:
The tf_proto_library is defined here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/platform/default/build_config.bzl#L26
and the cc_proto_library is defined here:
https://github.com/google/protobuf/blob/master/protobuf.bzl#L109
bazel version:
Build label: 0.2.3-homebrew
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 17 15:07:52 2016 (1463497672)
Build timestamp: 1463497672
Build timestamp as int: 1463497672
Could you paste your actual code and the error message you're getting? It looks like there are several problems and I'm not sure which are copy-paste errors and which are code.
I'd guess the issue you're having is that you cannot list files (nor filegroups) as deps in a cc_library rule, and ":protos_all_cc" is a filegroup. deps must be other cc_libraries (it's "things this rule should link together"). But it's very hard to tell with out the error message nor definition of protos_all_cc.
The srcs attribute should be a list, so your definition of protos_all should be
tf_proto_library(
name = "protos_all",
srcs = [":protos_all_src"], # note the list here
...
)
Maybe this is just a typo in the question, and the real problem is something else?
I get weird Permission denied problems when I try your filegroup approach.