Building gcloud api using bazel for windows - c++

I want to add speech to text feature to my c++ application for windows, so I'm trying to build googleapi. I downloaded bazel and typed bazel //... in cmd and got error:
E:/dev/gapi/googleapis-master/WORKSPACE:116:1 ERROR: An error occurred during the fetch of repository
'com_google_api_gax_java_properties': Could not load dependencies
from properties file, error_code %s256 ERROR: no such package
'#com_google_api_gax_java_properties//': Could not load dependencies
from properties file, error_code %s256 ERROR: no such package
'#com_google_api_gax_java_properties//': Could not load dependencies
from properties file, error_code %s256 INFO: Elapsed time: 147.675s
INFO: 0 processes. FAILED: Build did NOT complete successfully (0
packages loaded)

Related

Build and run a Qt application on macOS via Bazel

I tried to build and run a Qt5 (5.15.2) application on macOS (10.15.7) using Bazel 5.0.0.
Unfortunately, I run into some problems.
The building part seems to work, but not the run part.
I installed Qt5 on my machine using Homebrew:
brew install qt#5
brew link qt#5
I adapted https://github.com/justbuchanan/bazel_rules_qt/ to my needs. See this PR. When I try to run:
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
I receive the runtime error:
dyld: Symbol not found: __ZN10QByteArray6_emptyE
Steps to reproduce the issue:
# brew install bazel # Install Bazel
# brew install qt#5 # Install Qt5
git clone https://github.com/Vertexwahn/bazel_rules_qt.git
cd bazel_rules_qt
git checkout add-macos-support
bazel build --cxxopt=-std=c++17 //... # should work
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main # should give you the error message
Nevertheless, building everything using bazel build --cxxopt=-std=c++17 //... seems to work.
I am not 100% sure if the link options -F/usr/local/opt/qt5/Frameworks and -framework QtCore, etc. are correct.
Maybe someone can confirm this.
Did I use the correct link options?
For me, it is a bit unclear what dependencies the main binary expects. I tried to copy QtCore.framework to the location of the main binary manually but this does not change the error message.
What files does the main binary expect?
If I try to run macdeployqt on my main binary I get also some errors. I do within my workspace root dir a cd bazel-bin/tests/qt_resource and run then /usr/local/opt/qt5/bin/macdeployqt main:
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "main"
WARNING: Perhaps macdeployqt was already used on "main" ?
WARNING: If so, you will need to rebuild "main" before trying again.
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/strip: can't open file: (No such file or directory)\n"
ERROR: ""
My hope was that macdeployqt would collect all needed resources for me. Any idea why this is not working?
How can macdeployqt be used to collect all needed dependencies for the main binary?
If I convert my main to an app via lipo -create -output universall_app main and do then a /usr/local/opt/qt5/bin/macdeployqt universall_app I get the same error message.
The CMake approach
To make sure that there is no general problem with my system setup I tried to use CMake to build a Qt5 application:
git clone https://github.com/euler0/mini-cmake-qt.git
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 .
make -j
This produces an example.app.
With a double click on this application bundle,
the application can be started.
This worked on my system.
Future directions
It seems that rules_apple can be used to create an application bundle.
I am not sure if I need to transform my Qt application binary to an app bundle to be able to execute it.
One could use --sandbox_debugto identify what Bazel is doing and dtruss for the CMake version to compare the differences.
I am currently not sure what trying to do next and hope for an easy solution. I am also fine with a Qt6 solution.
Update: Alternative Answer
It would also be helpful if someone can point out how to build a minimal Qt application using make only on macOS and a brew installed Qt5 or tell me what the linker and compiler options must look like.
I followed your steps with Mac OSX 10.15.7, Qt (installed by homebrew) 5.15.1 and both bazel 4.2.2-homebrew and 5.0.0-homebrew and initially I could not build the project from git:
* 3fe5f6c - (4 weeks ago) Add macOS support — Vertexwahn (HEAD -> add-macos-support, origin/add-macos-support)
This is the result that I get when building:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
INFO: Found 14 targets...
ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
#include <QtQml/QQmlApplicationEngine>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
INFO: Elapsed time: 0,594s, Critical Path: 0,32s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully
After playing around with headers and include paths in qt.BUILD:
diff --git a/qt.BUILD b/qt.BUILD
index 517c8db..8f110b5 100644
--- a/qt.BUILD
+++ b/qt.BUILD
## -28,11 +28,12 ## QT_LIBRARIES = [
cc_library(
name = "qt_%s_osx" % name,
# When being on Windows this glob will be empty
- hdrs = glob(["%s/**" % include_folder], allow_empty = True),
+ hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
includes = ["."],
linkopts = ["-F/usr/local/opt/qt5/lib"] + [
"-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
],
+ strip_include_prefix= "include"
# Available from Bazel 4.0.0
# target_compatible_with = ["#platforms//os:osx"],
)
I could build and run the project:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
INFO: Found 14 targets...
INFO: Elapsed time: 11,761s, Critical Path: 7,23s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
% bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tests/qt_resource:main up-to-date:
bazel-bin/tests/qt_resource/main
INFO: Elapsed time: 3,657s, Critical Path: 0,00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
opened resource file
file1
Related to your question whether the linker options are correct
-F/usr/local/opt/qt5/Frameworks -framework QtCore
Yes they are correct, you could alternatively use -F/usr/local/opt/qt5/lib (as you are already using in qt.BUILD) as all the files under the Frameworks folder are links to the lib folder.
With macdeployqt and lipo I get the same results as in the OP even after the test is running successfully.

Building gRPC C++ from source

I am trying to build gRPC c++ from source from Build gRPC C++
I have already installed bazel.
Though when I tried to build I am seeing following error.
$ bazel build :all
Starting local Bazel server and connecting to it...
ERROR: /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl:39:25: Traceback (most recent
call last):
File "/home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl", line 37
repository_rule(<2 more arguments>)
File "/home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/io_bazel_rules_python/python/pip.bzl", line 39, in repositor
y_rule
attr.label(allow_files = True, <2 more arguments>)
'single_file' is no longer supported. use allow_single_file instead. You can use --incompatible_disable_deprecated_attr_params=false to temporarily disable th
is check.
ERROR: error loading package '': Extension file 'python/pip.bzl' has errors
ERROR: error loading package '': Extension file 'python/pip.bzl' has errors
INFO: Elapsed time: 7.505s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
Could someone point what I am missing here.
When I tried to run bazel info, I am getting following error.
$ bazel info --incompatible_disable_deprecated_attr_params=false
ERROR: /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:771:21: name 'FileType' is not defined
ERROR: error loading package '': in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/python/rules.bzl: in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/cpp/rules.bzl: in /home/bigz/.cache/bazel/_bazel_bigz/a68d37101a3d172c639dd67a1941f719/external/org_pubref_rules_protobuf/protobuf/rules.bzl: Extension 'protobuf/internal/proto_compile.bzl' has errors
Though bazel --version shows as bazel 2.0.0.
$ bazel --version
bazel 2.0.0
The latest commit of gRPC is 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14
$ git log -1
commit 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 (HEAD, tag: v1.20.0)
Merge: 1b488f8361 ae72bf76b3
Author: Lidi Zheng <scallopsky#gmail.com>
Date: Mon Apr 15 15:38:24 2019 -0700
Merge pull request #18760 from lidizheng/v1.20.x
Bump version to v1.20.0
The commit of grpc you are trying to build is not compatible with the version of bazel you have installed (2.0.0).
The commit 9dfbd34f5c0b20bd77658c73c59b9a3e4e8f4e14 is quite old (15 April 19), where the HEAD of that repo (at the time of writing this) is at eba60d8dbe4099c34b8097b2c89998d4484740ac, which now in BUILDING.md shows you need at least version 1.0.0 (there is a bazel wrapper at tools/bazel that will intercept and use 1.0.0 anyway)
For your specific commit however, trying different versions, I was able to build :all label with bazel version 0.20.0
I'd recommend trying bazelisk. You can add it to your PATH, add a .bazelversion file to the repository and bazelisk will take care of downloading the required bazel version.

Issue in building Tensorboard 1.13.1 from source (cfg must be either 'host' or 'target')

I am trying to build Tensorboard (1.13.1) from source. I am using Bazel version 0.26.0 (built from source) and JDK version 11.0.3. I am getting following error during build:
# bazel build --incompatible_disallow_filetype=false --incompatible_bzl_disallow_load_after_statement=false tensorboard
Starting local Bazel server and connecting to it...
ERROR: /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/io_bazel_rules_closure/closure/compiler/closure_js_library.bzl:343:17: Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/io_bazel_rules_closure/closure/compiler/closure_js_library.bzl", line 335
rule(implementation = _closure_js_lib..., <2 more arguments>)
File "/root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/io_bazel_rules_closure/closure/compiler/closure_js_library.bzl", line 343, in rule
attr.label_list(cfg = "data", allow_files = True)
cfg must be either 'host' or 'target'.
ERROR: error loading package '': in /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/io_bazel_rules_closure/closure/defs.bzl: Extension file 'closure/compiler/closure_js_library.bzl' has errors
ERROR: error loading package '': in /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/io_bazel_rules_closure/closure/defs.bzl: Extension file 'closure/compiler/closure_js_library.bzl' has errors
INFO: Elapsed time: 14.290s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
If I search and replace the word 'data' with 'host' from .bzl files, I start getting another error:
# bazel build --incompatible_disallow_filetype=false --incompatible_bzl_disallow_load_after_statement=false tensorboard
ERROR: error loading package '': in /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/org_tensorflow/tensorflow/workspace.bzl: Label '#org_tensorflow//third_party:nccl/nccl_configure.bzl' crosses boundary of subpackage '#org_tensorflow//third_party/nccl' (perhaps you meant to put the colon here: '#org_tensorflow//third_party/nccl:nccl_configure.bzl'?)
ERROR: error loading package '': in /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/org_tensorflow/tensorflow/workspace.bzl: Label '#org_tensorflow//third_party:nccl/nccl_configure.bzl' crosses boundary of subpackage '#org_tensorflow//third_party/nccl' (perhaps you meant to put the colon here: '#org_tensorflow//third_party/nccl:nccl_configure.bzl'?)
INFO: Elapsed time: 15.377s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
Correcting the error by replacing,
load("//third_party:nccl/nccl_configure.bzl", "nccl_configure")
by
load("//third_party/nccl:nccl_configure.bzl", "nccl_configure")
in the cache file,
/root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/org_tensorflow/tensorflow/workspace.bzl
Solves the error but now getting this error:
# bazel build --incompatible_disallow_filetype=false --incompatible_bzl_disallow_load_after_statement=false tensorboard
ERROR: /root/.cache/bazel/_bazel_root/4e113d18791d4c114d32fe59cdd54b1a/external/org_tensorflow/tensorflow/workspace.bzl:18:1: file '#io_bazel_rules_closure//closure:defs.bzl' does not contain symbol 'filegroup_external'
ERROR: error loading package '': Extension file 'tensorflow/workspace.bzl' has errors
ERROR: error loading package '': Extension file 'tensorflow/workspace.bzl' has errors
INFO: Elapsed time: 1.113s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
Now I am stuck. Any pointers highly appreciated!

build in Maven 2.2.1 with JDK 1.6 and JDK 1.7 what changes are needed in pom.xml

While building the project in Maven 2.2.1 as some of my projects are in JDK1.6 and some in JDK 1.7.I need to build the entire modules.
What are the changes shall I need to make as I am getting the below error:
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
abc\TestSerializeUtil.java:[54,61] [unchecked] unchecked conversion
could not parse error message: required: Map
found: Map
abc\TestSerializeUtil.java:93: warning: [unchecked] unchecked conversion
Map mapResult = SerializeUtil.fromXML(xml, Map.class, classLoader);
^

Build Tensorflow with Bazel

I would like build tensorflow with Bazel to use the compiled libary in c++. I run the following commands in cmd.
C:\Users\Furkan\Desktop\tensorflow-1.14.0>bazel build --config=opt
WARNING: Usage: bazel build <options> <targets>.
Invoke `bazel help build` for full description of usage and options.
Your request is correct, but requested an empty set of targets. Nothing will be built.
INFO: Build option --define has changed, discarding analysis cache.
INFO: Analyzed 0 targets (0 packages loaded, 0 targets configured).
INFO: Found 0 targets...
INFO: Elapsed time: 0.124s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
After that they create the folders in tensorflow, but the folders are empty.. What I do wrong??
bazel: 0.25.2
tensorflow: 1.14.0
I guess you're typing an incomplete command, you should type:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
The
//tensorflow/tools/pip_package:build_pip_package
is the location of the BUILD file, if you're not including it bazel does not know what to build. Including that in your command should solve the issue.