Building mediapipe fails with both GCC and Clang - c++

I am trying to build Hello World example of Mediapipe in C++. These are my exports in .bash_profile:
export PATH=$PATH:$(go env GOPATH)/bin
export GLOG_logtostderr=1
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
#export CC=/usr/bin/gcc
#export CXX=/usr/bin/g++
export BAZEL_CXXOPTS="-std=gnu++17"
then I run this, fallowing the instructions:
bazelisk run --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 --sandbox_writable_path ~/.ccache --sandbox_debug --verbose_failures mediapipe/examples/desktop/hello_world:hello_world
the effect being "no member named 'max' in the global namespace" error on this line:
if (x->version == std::numeric_limits<uint32_t>::max()) {
that's on Clang I've only used because GCC11 changed how it now doesn't include <limits> so with CC/CXX variables set to gcc/g++, it gives "'::max' has not been declared; did you mean std::max?" errors... did Clang made similar changes? I'm on Fedora, I don't have access to old GCC10.

mediapipe depends on an old version of abseil c++ that does not include a commit necessary to work on newer libstdc++ versions. So, com_google_absl in the mediapipe WORKSPACE needs an update.

Related

Problem with using the NDK with other build systems

I am learning Use the NDK with other build systems. Trying to get the example for Autoconf to work. It looks like ./configure --host $TARGET is working as expected. But I get an error while executing make:
arm/filter_neon.S -fPIC -DPIC -o arm/.libs/filter_neon.o
arm/filter_neon.S:24:17: error: expected string in directive
.section __LLVM,__asm
^
make[1]: *** [Makefile:1187: arm/filter_neon.lo] Error 1
I am new to Android and Linux. Here is the .sh-file I am using on Ubuntu:
#!/bin/bash -v
# Check out the source.
git clone https://github.com/glennrp/libpng
cd libpng
# Only choose one of these, depending on your build machine...
#export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
# Only choose one of these, depending on your device...
#export TARGET=aarch64-linux-android
export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
#export TARGET=x86_64-linux-android
# Set this to your minSdkVersion.
export API=21
# Configure and build.
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
./configure --host $TARGET
make
What am I doing wrong, why the tutorial example doesn't work? Thank you in advance.
There are bug in libpng. Do not use cloning from github. Use released version. There are different link on github https://github.com/glennrp/libpng/releases/tag/v1.6.35
Change this script from official doc and do not clone github repo, just download archive and run this script inside of it.
For me all is working.
Hm. This is my fault :)
I added this to support bitcode enabled builds with non-Apple LLVM. It works there but not on Android. Using the release as suggested by #Alexandr Kirilov is a good call, but this should be fixed upstream in libpng as well.
It needs to be guarded by __APPLE__ as well, see https://github.com/glennrp/libpng/pull/383
Unfortunately, when I patched this I only tested it on macOS/iOS platforms and not on other arm platforms :(

bazel Failed to create temporary file

I have download the git repo containing the c++ tutorial for bazel and I am trying to compile the examples.
When performing the command bazel build //main:hello-world, I get the following error:
ccache: error: Failed to create temporary file for /home/username/.ccache/tmp/tmp.cpp_stderr: Read-only file system
Thus I tried several actions: sudo bazel, change permission to /.ccache/tmp/ folder but none has worked. How can I get ride of this error ?
I work on fedora27.
The reason for this error is that ccache is used and requires write access ~/.ccache.
See in Ondrej's comment to: Bazel building C++ sample with ccache fails
Using --sandbox_writable_path ~/.ccache fixes the issue without disabling the sandbox feature.
Solved using the option --strategy=CppCompile=standalone :
bazel build //main:hello-world --strategy=CppCompile=standalone

Compiling native node addon with c++ 17 inside fails during npm install on ubuntu

I have native add-on for nodejs that uses c++17 features, specifically "shared_mutex".
When I call npm install which downloads and compiles the add-on i get an error:
The linux machine has GCC 6.0 installed.
My Binding.gyp uses the following config to catch os type and add flags accordingly:
'conditions': [
['OS=="linux"', {
'CXXFLAGS': [
'-std=c++1z'
]}],
** i've also tried with '-std=c++17', '-std=c++1z'.
What am I missing?
Update:
1. Updated ubuntu 16.04 to GCC 16.04 and made it default.
2. It seems that when i try to compile it manualy using node-gyp rebuild "CXXFLAGS='-std=c++17'" it works and brings only one error:
"shared_,utex in namespace std does not name a type std::shared_mutex file mutex" (the last error)
Problem solved. For anyone who has the same issue, bind.gyp should use cflags_cc instead of cxxflags.

How do I specify LDFLAGS and CPPFLAGS for ./configure?

I am using a Mac running OS X 10.8.3. I am trying to compile cgminer 3.0.0. On my first run of ./configure I got the message:
checking for LIBCURL... no
checking for LIBCURL... no
configure: error: Missing required libcurl dev >= 7.18.2
So I installed the latest version of libcurl using homebrew:
brew install curl
That seemed to do the trick. I got this message:
downloaded: /Library/Caches/Homebrew/curl-7.30.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/curl/7.30.0
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
The libcurl provided by Leopard is too old for CouchDB to use.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include
==> Summary
/usr/local/Cellar/curl/7.30.0: 75 files, 2.0M, built in 61 seconds
Okay, so it's installed but not symlinked into /usr/local, that's fine with me. I tried this:
export LDFLAGS=-L/usr/local/opt/curl/lib
export CPPFLAGS=-I/usr/local/opt/curl/include
./configure
But I got the same message: configure: error: Missing required libcurl dev >= 7.18.2
So I tried this:
env LDFLAGS=-L/usr/local/opt/curl/lib CPPFLAGS=-I/usr/local/opt/curl/include ./configure
I'm still getting the "missing required libcurl" message. Any ideas?
After some more thorough investigation, I determined that the configure file for cgminer does not pay attention to LDFLAGS or CPPFLAGS when testing for libcurl. Instead, it checks for LIBCURL_CFLAGS and LIBCURL_LIBS. So, I tried:
export LIBCURL_CFLAGS=-I/usr/local/opt/curl/include
export LIBCURL_LIBS=-L/usr/local/opt/curl/lib
./configure
and I got:
checking for LIBCURL... yes
And the rest of the configuration went off without a hitch. SUCCESS!

GLIBCXX not found when compiling vtk example under mex

I have been trying to follow this example for compiling vtk in MATLAB using mex, on an Ubuntu 11.10. The mex command I used is as follows:
mex -I/usr/include/vtk-5.6 vtk_file.cpp -L/usr/lib/ -lvtkFiltering -lvtkRendering -lvtkCommon
After compilation I have a .mexa64 file.
However, when I try to run the file I end up with the following error:
Invalid MEX-file '/home/bill/Documents/MATLAB/vtk/vtk_file.mexa64':
/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.11' not found (required by /usr/lib/libvtkFiltering.so.5.6)
How can I ensure that glibcxx is found? I would have assumed that it would be included by default in the compilation.
Matlab uses its own glibc librarires, and it's often a big mess because of that.
To solve that problem you should first try to ensure that matlab use a supported version of gcc. Do you get a warning about that when you compile?
If you are sudoer, you can also "force" matlab to use the standard glibc, by doing something like that (I did it, and it works fine):
cd /usr/local/MATLAB/R2011a/sys/os/glnxa64
sudo mkdir old
sudo mv libstdc++.so.6* old
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
Many people complain about that on the internet, there are different solutions, if those two ones don't work.