Nmake: Placeholder/Wildcards in Targets - placeholder

I already have a Makefile to build my software on Linux. But now i need a .mak file to build on Windows.
However, it's not possible to use Placeholders in Nmake like this way:
build: mytarget_foo
#target build
mytarget_%:
#target mytarget_% to match mytarget_foo
How to use placeholders in Nmake?
Thanks in advance.
EDIT: console output:
'MAKE : fatal error U1073: don't know how to make 'mytarget_foo
Stop.

Use the asterisk. Here's the doc.
mytarget_*:
# target mytarget_* to match mytarget_foo

Related

How to inspect #local_config_platform//:host?

I'm running into some toolchain issues, with errors like:
INFO: ToolchainResolution: Type #io_bazel_rules_go//go:toolchain: target platform #local_config_platform//:host: Rejected toolchain #go_sdk//:go_linux_amd64-impl; mismatching values: linux, x86_64
INFO: ToolchainResolution: Type #io_bazel_rules_go//go:toolchain: target platform #local_config_platform//:host: No toolchains found.
but I believe I am running on x86_64 and Linux, but that would be made clear by inspecting the generated constraints.
This was mentioned earlier, but I was unable to find said-generated file.
And in case it ever helps anyone else, I'm running popos.
Thanks!
Use query --output=build to dump the rule:
$ bazel query --output=build #local_config_platform//:host
# /home/user/.cache/_bazel_cache/bf5544946d234767647dbf413a7bc3c9/external/local_config_platform/BUILD.bazel:4:9
platform(
name = "host",
constraint_values = ["#platforms//cpu:x86_64", "#platforms//os:linux"],
)
The comment line even tells you were to find the original generated BUILD file.

Yocto: cmake is missing header - how to DEPEND dev-package?

I am including opencv with custom build parameters in my Yocto image. For that I have an opencv_4.1.0.bbappend recipe, in which I set custom options, specifically FFMPEG. The recipe goes something like this:
DEPENDS += "ffmpeg libpng"
EXTRA_OECMAKE_append += "-DWITH_FFMPEG=ON -DWITH_GTK=OFF" # and some other options
During configure I get cmake errors and can't seem to figure out, how to satisfy the header dependencies. The errors go like this (I assume this is the reason for do_configure to fail):
CheckIncludeFile.c:1:10: fatal error: /home/janos/dev/yocto/build/tmp/work/core2-64-poky-linux/opencv/4.1.0-r0/recipe-sysroot/usr/include/libpng/png.h: No such file or directory
1 | #include </home/janos/dev/yocto/build/tmp/work/core2-64-poky-linux/opencv/4.1.0-r0/recipe-sysroot/usr/include/libpng/png.h>
CheckIncludeFile.c:1:10: fatal error: sys/videoio.h: No such file or directory
1 | #include <sys/videoio.h>
Focusing on the missing png.h header first, I am tempted to depend libpng-dev, as I also would apt install it. But there is no package for it.
When I search oe-pkgdata-util list-pkg-files -p libpng, I can find the header in a libpng-dev package:
...
libpng-dev:
/usr/bin/libpng-config
/usr/bin/libpng16-config
/usr/include/libpng16/png.h
/usr/include/libpng16/pngconf.h
/usr/include/libpng16/pnglibconf.h
/usr/include/png.h
...
...
I can also find it in libpng-src and also ffmpeg-src package (oe-pkgdata-util find-path "*png.h" was my friend). But all of these -dev and -src packages I cannot depend on in DEPENDS.
How can I get my recipe to know those headers?
Target machine is raspberrypi4-64, on which the recipe is configuring and compiling well - it fails when I build for qemux86-64, which I use for testing. Namely, my test command is MACHINE="qemux86-64" bitbake opencv.
It doesn't really answer the question which I though was the question - but this is how the opencv recipe is easily configured:
PACKAGECONFIG = "python3 libav libv4l v4l"
Looking into the opencv 4.1.0 recipe (opencv_4.1.0.bb), I could see that FFMPEG gets enabled with the libav configurable option.
As a result of depending FFMEPG, I had to whitelist "commercial" licenses in my local.conf file:
LICENSE_FLAGS_WHITELIST = "commercial"
Looking into ./build/tmp/work/aarch64-poky-linux/opencv/4.1.0-r0/temp/log.do_configure shows that opencv is correctly configured without GUI, with v4l/v4l2:, FFMPEG, python3, etc.
And so python3 in the resulting image:
import cv2
print(cv2.getBuildInformation())

fatal error: zbar.h: No such file or directory

I downloaded the zbar library and cloned the opencv-zbar repo in my home directory. Then I ran the following command $cmake . which gave my the error
-- Could NOT find ZBAR (missing: ZBAR_LIBRARIES ZBAR_INCLUDE_DIR)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ZBAR_LIBRARIES
linked by target "zbar_opencv" in directory /home/surabhi/opencv-zbar
-- Configuring incomplete, errors occurred!
See also "/home/surabhi/opencv-zbar/CMakeFiles/CMakeOutput.log".
I then made two changes in my CMakeCache.txt as follows
//Path to a file.
ZBAR_INCLUDE_DIR:PATH=/usr/include/zbar
//Path to a library.
ZBAR_LIBRARIES:FILEPATH=/usr/lib/libzbar.so
because the were set to NOTFOUND.
It then gave me no errors
-- Found ZBAR: /usr/lib/libzbar.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/surabhi/opencv-zbar
But when I run make
It gives the error:
fatal error: zbar.h: No such file or directory
#include <zbar.h>
^
compilation terminated.
I don't understand why I get this error as It says Found ZBAR when I run cmake.
Thanks in advance
You need to do actually use the include dirs somewhere in your CMakeLists.txt so CMake knows that you actually want to use these include paths.
Examples:
include_directories(${ZBAR_INCLUDE_DIR})
Or the more modern, recommended way:
target_include_directories(zbar_opencv PRIVATE ${ZBAR_INCLUDE_DIR})

Bazel rule is missing dependency for clang's sanitize-blacklist

I'm trying to add ASAN sanitize to our project which uses Bazel and stuck with the following problem. I've added blacklist for sanitize in our bazel.rc
build:asan --copt -fsanitize=address
build:asan --linkopt -fsanitize=address
build:asan --copt -fsanitize-blacklist=blacklist.txt
but when I build a target I get missing dependency error
ERROR: memory/main/BUILD:1:1: undeclared inclusion(s) in rule '//main:memory_leak':
this rule is missing dependency declarations for the following files included by 'main/memory_leak.cpp':
'memory/blacklist.txt'
Target //main:memory_leak failed to build
It seems that blacklist.txt should be added to the build rule in BUILD file, but we cannot really do that for all gazillion rules we already have. Is there a way to add a global dependency for all rules or something like this?
Normally the C++ toolchain should have the dependency but it is auto-generated.
You can always create a macros to overwrite the default cc_library:
In tools/build_rules/prelude_bazel:
load('#//tools/build_rules:cc.bzl', 'cc_library')
in tools/build_rules/cc.bzl:
def cc_library(data=[], **kwargs):
native.cc_library(data = data + ['//memory:blacklist.txt'], **kwargs)
in memory/BUILD:
exports_files(['blacklist.txt'])
Also add an empty file tools/build_rules/BUILD.
The first file is importing the cc_library in the begining of all your file, the second file is defining a new cc_library that adds the missing dependency and the third file just expose the 'blacklist.txt' to all the other rules. The last empty file is just to define a package for Bazel that is needed to load the cc.bzl file.

OpenCV linemod not cv member

I try to install a ROS indigo package jsk_recognition for chessboard detection and relative position, I have opencv-3.0.0-rc1 on Ubuntu 14.04. When I try to catkin_make the package I receive build errors, quit a lot, the full report is here, but it starts like:
[ 73%] Building CXX object
vision/jsk_recognition-master/jsk_perception/CMakeFiles/roi_to_mask_image.dir/roi_to_mask_image.cpp.o
/home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_perception/src/linemod.cpp:69:57:
error: ‘linemod’ is not a member of ‘cv’ std::vector<CvPoint>
maskFromTemplate(const std::vector<cv::linemod::Template>& templates,
^ /home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_perception/src/linemod.cpp:69:57:
error: ‘linemod’ is not a member of ‘cv’
/home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_perception/src/linemod.cpp:69:78:
error: template argument 1 is invalid std::vector<CvPoint>
maskFromTemplate(const std::vector<cv::linemod::Template>& templates,
^
/home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_perception/src/linemod.cpp:69:78:
error: template argument 2 is invalid
/home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_perception/src/linemod.cpp:69:57:
error: ‘linemod’ is not a member of ‘cv’ std::vector<CvPoint>
maskFromTemplate(const std::vector<cv::linemod::Template>& templates,
the problem seams to be with the linemod class, which in the online opencv documentation exist but in my case the compiler does not recognise it. The linemod.h header file can't be find in any opencv folder only in:
./home/elod/catkin_ws/src/vision/jsk_recognition-master/jsk_pcl_ros/include/jsk_pcl_ros/linemod.h
./opt/ros/indigo/include/jsk_pcl_ros/linemod.h
./usr/include/pcl-1.7/pcl/recognition/linemod.h
Is this module missing somhow my OpenCV installation or why cant find it in the cv namespace?
In my old Opencv 2.4.11 (uninstalled) seams to be included this module, but I migrated all my stuff to 3.0.0.
Any ideas how to solve it?
UPDATE
A very important observation is that the above mentioned pkg is for Opencv2.4 and I'm using 3.0! Some stuff was moved or removed from the new version like cvSnakeImage, which also appears in this pkg.
An other question would be: how to replace the cvSnakeImage or with what can be replaced?
Did you build from scratch (clean build directory) ?
You could try adding cv:: namespace into *.hpp
-<linemod::Match>
+<cv::linemod::Match>
And/or try adding "#include <opencv2/rgbd/linemod.hpp>" into the same file.

Resources