How to build boost::fiber alongside other boost libraries? - c++

I'm trying to build boost::fiber alongside other boost libraries on Ubuntu. I downloaded boost version 1.61 from sourceforge. And I downloaded version 1.0 of boost::fiber from github. I copied directory named fiber in boost/libs sub-directory in boost distribution. The command I used for building is:
sudo ./b2 cxxflags="-std=c++14" --build-type=minimal --build-dir=/home/bobeff/projects/build --layout=system install
The used version of g++ is:
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
boost::fiber failed to compile and the first of many errors is:
gcc.compile.c++ /home/bobeff/projects/build/boost/bin.v2/libs/fiber/build/gcc-5.4.0/release/link-static/threading-multi/algorithm.o
In file included from libs/fiber/src/algorithm.cpp:9:0:
./boost/fiber/fiber_context.hpp:91:5: error: invalid use of template-name ‘boost::context::execution_context’ without an argument list
context::execution_context ctx_;

Did you build boost.context with C++14 too?
Check if all required C++-features (lambdas, nullptr etc.) are supported.
You see this at stdout when you run b2/bjam - maybe you have to call b2/bjam with option --reconfigure.
As an alternative you could wait till boost-1.62 is released (28.09.2016?).

Related

Mac OS boost installed using macports collision with C++ version

Anyone know why sudo cmake --build ./build-clang --config Release results in
In file included from /opt/local/include/boost/asio/buffer.hpp:29:
/opt/local/include/boost/asio/detail/type_traits.hpp:89:12: error: no member named 'result_of' in namespace 'std'
using std::result_of;
~~~~~^
Despite the env variables being set?
$CC=clang
$CXX=clang++
$CC --version
Homebrew clang version 15.0.6
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
trying to build for Mac for the first time.
boost was installed using macports sudo port install boost +universal
I've heard result_of was deprecated in C++17 and removed in C++20 – how can I get around this issue? I'm working with C++20
when I add
target_compile_definitions(${TARGET_NAME}
PRIVATE
BOOST_ASIO_HAS_STD_INVOKE_RESULT=1)
I get the same errors
I uninstalled and reinstalled the latest version using brew and now I get /opt/local/include/cpprest/http_client.h:68:10: fatal error: 'boost/asio/ssl.hpp' file not found #include "boost/asio/ssl.hpp"
The problem is that at the moment, MacPorts only supports up to Boost 1.76. By default, it will use std::result_of, which has been removed in C++20.
To solve this, you can manually define BOOST_ASIO_HAS_STD_INVOKE_RESULT, which should route usages of result_of to the C++20 compliant invoke_result within the source.
Note, this does not guarantee all other codes are C++20 compliant.
Alternatively, you can also manually install Boost, or install it through other package managers like Homebrew, which supports up to Boost 1.81

caffe: error with protobuf version

I've previously installed caffe and Fast-RCNN, so I should have all the required libraries and dependencies.
I need to install it again for another repository(https://github.com/ronghanghu/natural-language-object-retrieval) that uses Caffe.
When I run
make all
it gives me the following error:
CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:26:55: fatal error: google/protobuf/generated_enum_reflection.h: No such file or directory
#include <google/protobuf/generated_enum_reflection.h>
compilation terminated.
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
I thought maybe protobuf has been updated, and tried
protoc --version
which returns
libprotoc 2.5.0
It seems like newer version of protobuf has been released (2.6 or up).
So my question would be:
1) Is there a simple way to update it?
2) If I do update it, will it affect caffe and fast-rcnn that I previously installed, which depends on the older version of protobuf?
I suspect your problem is that you have multiple versions of protobuf in your include path. It may be picking up the headers from the older version instead of the latest. I can confirm that latest caffe (git master as of right now) compiles cleanly against the libprotobuf-dev-2.5.0-9ubuntu1 which is in ubuntu 14.04LTS.
I guess before you get this problem, you have used protoc to generate caffe.pb.h`. If you did, my solution maybe be useful to you.
Firstly, you should know how many protoc installed in your OS.
For example, in my OS:
Prompt> whereis protoc
protoc: /usr/bin/protoc /home/xxx/.conda/envs/python27/bin/protoc/usr/share/man/man1/protoc.1.gz
So, there are 2 protoc in my OS. You can use which protoc and protoc --version in order to find which version protoc is used default. In my OS:
Prompt> which protoc
/home/xxx/.conda/envs/python27/bin/protoc
Prompt>protoc --version
libprotoc 3.5.1
Finally, use another protoc to create caffe.pb.h again.
let the dir to caffe/src/caffe/proto, and execute:
/usr/bin/protoc --cpp_out=. caffe.proto
I solved this on my computer and maybe it can help you. My environment is Ubuntu16.04, and I installed Anaconda(for python2.7) before I install Caffe. It happens that I used conda to install libprotobuf-dev, and this leads to conflict with the caffe's 'sudo apt-get install libprotobuf-dev' command, for 'apt-get' and conda installed different on my computer which can be find by 'locate protobuf', so I remove the Anaconda's version of libprotobuf, and no problem happens again.
conda uninstall libprotobuf
When you install tensorflow before install Caffe, this problem will also happen, because of the libprotobuf conflict.
I solve the problem by
conda uninstall libprotobuf
then remove the caffe folder and download a new one
git clone https://github.com/BVLC/caffe.git
then do
make all -j8

How to use previous versions of g++

I am currently running a debian Jessy whose g++'s version is 4.9. For some reason I need to compile a code in g++-4.7 or previous version.
I got the files of gcc-4.7 and g++-4.7 from a debian wheezy of a friend who has g++-4.7.
I tried to make the apt-get install, it seemed to have worked for the gcc but not for the g++. I put the files in the /bin, but he doesn't seem to locate the g++-4.7 package.
When I try to compile my code I specify g++-4.7 but get the error :
g++: error trying to exec 'cc1plus': execvp: No such file or directory
Any idea how to figure this out?
My advise is to add the wheezy repositories to /etc/apt/sources.list and then install g++-4.7 using apt-get. Using this method you will also get bugfixes etc.
I guess, currently you're just having dependency Problems. These will be solved when you use apt-get.
It is very easy to install gcc from sources. Remember that you have also to use a binutils version which maps to the gcc version. Mostly it is possible to run older gcc versions on actual binutils, but I have also seen a problem during install.
I have installed a long list of gcc versions in /opt/
Simply copy an older gcc version somewhere in the file system can result in problems with using the correct library versions.
If you install different gcc versions and also the related libraries e.g.libstdc++ , don't forget to update your library data base ( ldconfig/LD_LIBRARY_PATH/...) Maybe http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html can help.

Cannot compile moses due to old boost version

I tried to compile moses(one of the statistical machine translation system) following the steps
specified here
I don't have root privileges so I used wget to installed newer version of boost. As the documentation above says, I tried to compile moses with the following command.
./bjam --with-boost=~/bin/boost_1_55_0 -j8
But it failed, getting following error.
You have Boost 104100. This package requires Boost at least 104400 (and preferably newer).
I am not familiar with bjam but my guess is that bjam is referencing the older version of boost even though I specified the location of new version of boost. How can I handle this problem?

Cmake Unable to find the requested Boost libraries. - boost_coroutine 1.53

Getting errors trying to build with boost on my Ubuntu x64 13.10
I installed libboost-all-dev
$ cmake . -DCMAKE_BUILD_TYPE=Release
statusCompiling on UNIX
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1126 (message):
Unable to find the requested Boost libraries.
Boost version: 1.53.0
Boost include path: /usr/include
The following Boost libraries could not be found:
boost_coroutine
I checked to see if boost_coroutine package is installed, but there is no version 1.53
$ apt-cache search libboost-coroutine
libboost-coroutine1.54-dev - provides a sort of cooperative multitasking on a single thread
It seems that libboost-all-dev package points to version 1.53, but somehow Ubuntu 13.10 is missing the corresponding coroutine subpackage.
If you have no particular attachment to version 1.53, try installing libboost1.54-all-dev instead. That package actually does have the coroutine subpackage available as you pointed out above, so you should at least be able to build your project.