linking of C++ and Python with BOOST; error = rule "Copyright" unknown in module "xml" - c++

I am trying to execute linking of C++ and Python with BOOST.
Using the example from https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/hello.html#tutorial.hello.let_s_jam, and issuing bjam at ~/libs/python/example/tutorial/ which contains these files:
hello.cpp hello.py Jamfile
The read-out from the console error is:
/home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam:12:
in load ERROR: rule "Copyright" unknown in module "xml".
Here is what I undertook to solve this problem:
I built boost from boost_1_71_0.tar.bz2 using the ./b2 file in the directory /boost/boost_1_71_0/ which is dated November 14, 2019.
My Ubuntu 18.04 system has a b2 link at /usr/bin/b2 -> bjam, which is older (March 6, 2018) and the bjam file (March 6, 2018).
No other bjam files exist on the system.
From bjam for boost 1.54, I tried:
sudo-apt install bjam
error: E: Package 'bjam' has no installation candidate.
All the programs in the user-config.jam file (e.g., c++, msvc/code, python3) are correct, which is located in my /home/benjamin/boost/boost_1_71_0/tools/build/example/.
For pity's sake and to help me (newbie), please advise.

Looking at error message it seems that error is with file /home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam
I checked with my local installation (which is boost 1.65.1), but I am not able to locate any file with name xml.jam. But I have few other .jam file at location /usr/share/boost-build/src/tools/types/. As example
asm.jam
# Copyright Craig Rodrigues 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
type ASM : s S asm ;
So it seems that your xml.jam either invalid OR few lines should be commented (as in above file).
Try below options.
Check your xml.jam, if there are any content which are not related jam then you should comment out information.
Rename your xml.jam to xml.jam.bkp. This file may not be needed.(Not needed in my case with boost 1.65.1)
Try to install everything from Ubuntu package manager and use that. You can install all boost module by sudo apt install libboost-all-dev. I tried https://github.com/boostorg/python/tree/develop/example code with my local installed boost (1.65.1) from package manager and it work fine.

Related

How to install Boost.Python using homebrew (on OSX)?

I'm trying to install Robot Operating System (ROS) Melodic on my mac (macOS 11.5.1). While compiling cv_bridge package, the compiler spit out an error related to the Boost.Python:
$ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH=$HOME/ros_catkin_ws/install_isolated/lib -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt#5/5.15.2;${HOME}/ros_catkin_ws/install_isolated" -DCMAKE_CXX_STANDARD=17 --pkg cv_bridge
.......... (some log messages are skipped)
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /Users/yj/ros_catkin_ws/devel_isolated/cv_bridge
-- Using CMAKE_PREFIX_PATH: /usr/local/Cellar/qt#5/5.15.2;/Users/yj/ros_catkin_ws/install_isolated
-- This workspace overlays: /Users/yj/ros_catkin_ws/install_isolated
-- Found PythonInterp: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2 (found suitable version "2.7.16", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
-- Using default Python package layout
-- Found PY_em: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/em.pyc
-- Using empy: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/em.pyc
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /Users/yj/ros_catkin_ws/build_isolated/cv_bridge/test_results
-- Found gtest: gtests will be built
-- Using Python nosetests: /Library/Frameworks/Python.framework/Versions/2.7/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- Found PythonLibs: /Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found version "2.7.16")
CMake Error at /usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake:141 (find_package):
Could not find a package configuration file provided by "boost_python"
(requested version 1.76.0) with any of the following names:
boost_pythonConfig.cmake
boost_python-config.cmake
Add the installation prefix of "boost_python" to CMAKE_PREFIX_PATH or set
"boost_python_DIR" to a directory containing one of the above files. If
"boost_python" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
/usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake:258 (boost_find_component)
/usr/local/Cellar/cmake/3.21.1/share/cmake/Modules/FindBoost.cmake:594 (find_package)
CMakeLists.txt:9 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/yj/ros_catkin_ws/build_isolated/cv_bridge/CMakeFiles/CMakeOutput.log".
See also "/Users/yj/ros_catkin_ws/build_isolated/cv_bridge/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "./src/catkin/bin/catkin_make_isolated", line 169, in <module>
main()
File "./src/catkin/bin/catkin_make_isolated", line 164, in main
override_build_tool_check=opts.override_build_tool_check,
File "./src/catkin/bin/../python/catkin/builder.py", line 1071, in build_workspace_isolated
_print_build_error(package, e)
File "./src/catkin/bin/../python/catkin/builder.py", line 810, in _print_build_error
cprint("#{rf}#!<==#| Failed to process package '#!#{bf}" + package.name + "#|': \n " + e_msg)
File "./src/catkin/bin/../python/catkin/builder.py", line 128, in cprint
print(fmt(msg), end=end)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/catkin_pkg/terminal_color.py", line 126, in fmt
return t.substitute(_ansi) + ansi('reset')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 176, in substitute
return self.pattern.sub(convert, self.template)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 173, in convert
self._invalid(mo)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 146, in _invalid
(lineno, colno))
ValueError: Invalid placeholder in string: line 2, col 437
It looks that the CMake was attempting to find the Boost.Python module, but it couldn't. I never installed it. So, I typed the following command to install the Boost.Python:
$ brew install boost-python
The homebrew responded:
$ brew install boost-python
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (osrf/simulation and homebrew/core).
==> New Formulae
cruft pari-galdata pari-seadata-big
eigenpy pari-galpol singularity
newrelic-infra-agent pari-seadata spot
==> Updated Formulae
Updated 43 formulae.
Error: boost-python has been disabled because it does not build!
It looks not possible to install the boost-python formula through homebrew. Then, how can I install it?
This is a short brief of my system configuration:
OS: macOS Big Sur (11.5.1)
Boost library is installed by homebrew (brew install boost)
boost version: 1.76.0
python version: 2.7.16
cmake version: 3.21.1
Edit 1
As #BTables said, I tried this command: brew install boost --with-python
It looks removed. My homebrew version is 3.2.8.
$ brew install boost --with-python
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (osrf/simulation and homebrew/core).
==> Updated Formulae
Updated 121 formulae.
Usage: brew install [options] formula|cask [...]
Install a formula or cask. Additional options specific to a formula may be
appended to the command.
Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run for
the installed formulae or, every 30 days, for all formulae.
-d, --debug If brewing fails, open an interactive
debugging session with access to IRB or a
shell inside the temporary build directory.
-f, --force Install formulae without checking for
previously installed keg-only or
non-migrated versions. When installing
casks, overwrite existing files (binaries
and symlinks are excluded, unless
originally from the same cask).
-v, --verbose Print the verification and postinstall
steps.
--formula, --formulae Treat all named arguments as formulae.
--env Disabled other than for internal Homebrew
use.
--ignore-dependencies An unsupported Homebrew development flag to
skip installing any dependencies of any
kind. If the dependencies are not already
present, the formula will have issues. If
you're not developing Homebrew, consider
adjusting your PATH rather than using this
flag.
--only-dependencies Install the dependencies with specified
options but do not install the formula
itself.
--cc Attempt to compile using the specified
compiler, which should be the name of the
compiler's executable, e.g. gcc-7 for GCC
7. In order to use LLVM's clang, specify
llvm_clang. To use the Apple-provided
clang, specify clang. This option will
only accept compilers that are provided by
Homebrew or bundled with macOS. Please do
not file issues if you encounter errors
while using this option.
-s, --build-from-source Compile formula from source even if a
bottle is provided. Dependencies will still
be installed from bottles if they are
available.
--force-bottle Install from a bottle if it exists for the
current or newest version of macOS, even if
it would not normally be used for
installation.
--include-test Install testing dependencies required to
run brew test formula.
--HEAD If formula defines it, install the HEAD
version, aka. main, trunk, unstable,
master.
--fetch-HEAD Fetch the upstream repository to detect if
the HEAD installation of the formula is
outdated. Otherwise, the repository's HEAD
will only be checked for updates when a new
stable or development version has been
released.
--keep-tmp Retain the temporary files created during
installation.
--build-bottle Prepare the formula for eventual bottling
during installation, skipping any
post-install steps.
--bottle-arch Optimise bottles for the specified
architecture rather than the oldest
architecture supported by the version of
macOS the bottles are built on.
--display-times Print install times for each formula at the
end of the run.
-i, --interactive Download and patch formula, then open a
shell. This allows the user to run
./configure --help and otherwise
determine how to turn the software package
into a Homebrew package.
-g, --git Create a Git repository, useful for
creating patches to the software.
--cask, --casks Treat all named arguments as casks.
--[no-]binaries Disable/enable linking of helper
executables (default: enabled).
--require-sha Require all casks to have a checksum.
--[no-]quarantine Disable/enable quarantining of downloads
(default: enabled).
--skip-cask-deps Skip installing cask dependencies.
--appdir Target location for Applications (default:
/Applications).
--colorpickerdir Target location for Color Pickers (default:
~/Library/ColorPickers).
--prefpanedir Target location for Preference Panes
(default: ~/Library/PreferencePanes).
--qlplugindir Target location for QuickLook Plugins
(default: ~/Library/QuickLook).
--mdimporterdir Target location for Spotlight Plugins
(default: ~/Library/Spotlight).
--dictionarydir Target location for Dictionaries (default:
~/Library/Dictionaries).
--fontdir Target location for Fonts (default:
~/Library/Fonts).
--servicedir Target location for Services (default:
~/Library/Services).
--input-methoddir Target location for Input Methods (default:
~/Library/Input Methods).
--internet-plugindir Target location for Internet Plugins
(default: ~/Library/Internet Plug-Ins).
--audio-unit-plugindir Target location for Audio Unit Plugins
(default:
~/Library/Audio/Plug-Ins/Components).
--vst-plugindir Target location for VST Plugins (default:
~/Library/Audio/Plug-Ins/VST).
--vst3-plugindir Target location for VST3 Plugins (default:
~/Library/Audio/Plug-Ins/VST3).
--screen-saverdir Target location for Screen Savers (default:
~/Library/Screen Savers).
--language Comma-separated list of language codes to
prefer for cask installation. The first
matching language is used, otherwise it
reverts to the cask's default language. The
default value is the language of your
system.
-q, --quiet Make some output more quiet.
-h, --help Show this message.
Error: invalid option: --with-python
$ brew --version
Homebrew 3.2.8
Homebrew/homebrew-core (git revision 6614f2a9b0; last commit 2021-08-18)
I was facing the same issue, I tried the following command and I worked:
$ brew install boost-python3
Don't know if ROS's cmake is set up to detect/use it since your other detections are for python2, but there is a another cask for python3: brew install boost-python3
Run brew install boost --with-python then do brew install boost-python.
I would also like to warn you that running Melodic(or really any OSX release of ROS) isn't something I would recommend. Specifically with OSX, the build is pretty experimental and not exactly stable or complete.
Update 2022
As #minari kotori mentioned, brew install boost --with-python does not build.
However, you can try building both boost and boost-python from source:
brew install --build-from-source -vd boost boost-python
If this doesn't work, you can try if boost_python3 solves your problem:
brew install boost
and then
brew install boost_python3.
Worked for me on macOS Monterey.

Unable to install R package requiring compiled C++ code (macOS Big Sur 11.4)

After updating to macOS Big Sur 11.4 and installing the latest versions of R (4.1.0), RStudio (1.4.1717) and Xcode (12.5.1) (for Command Line Tools), I am unable to build and install my R package from source (which relies on complied C++ code) via devtools::build() and devtools::install().
Every time I do this in RStudio, I receive the error message:
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
When I call the above, I am prompted to select "Yes" to install the build tools. However, when I nothing happens.
I have checked to ensure Xcode CLT is installed, and sure enough, it is:
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
My package relies on both Rcpp and RcppArmadillo. I have installed these within RStudio. devtools is also installed.
I cannot even install my package directly from GitHub via devtools::install_github()
Any ideas on what could be going on here and how I can resolve the issue?
I followed the steps in this post:
clang-7: error: linker command failed with exit code 1 for macOS Big Sur
including altering the Makevars as per the above post.
If it helps, here is my old Makevars
## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here. It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Thanks!

cmake error libcurl not found, but libcurl4 is installed

I am trying to compile the Springlobby version 268 client from the open source game TA-Spring. However the newest version (271) compiles just fine. But when I try to compile version 268 I get the CMake-error:
CMake Error at /usr/share/cmake-3.18/Modules/FindCURL.cmake:163 (message):
CURL: Required feature libcurl is not found
Call Stack (most recent call first):
src/CMakeLists.txt:127 (FIND_PACKAGE)
I am compiling on Debian testing and tried the libraries libcurl4-openssl-dev, libcurl-gnutls-dev and libcurl4-nss-dev all without success.
game: https://springrts.com
lobby 0.271: https://github.com/springlobby/springlobby
lobby 0.268: https://github.com/springlobby/springlobby/tree/0.268
install from source: https://github.com/springlobby/springlobby/wiki/Installfromsource
Building the lobby from git repo:
git clone --recursive https://github.com/springlobby/springlobby.git
cd springlobby
cmake .
make
make install
The Springlobby version 271 uses libcurl4-openssl-dev but version 268 seemingly links to an older libcurl.
Version 268 incorrectly calls find_package (src/CMakeLists.txt:127):
FIND_PACKAGE( CURL REQUIRED libcurl )
The last parameter libcurl is interpreted (according to find_package documentation) as the element of COMPONENTS list, and in case of FindCURL.cmake it is treated as PROTOCOL/FEATURE specification. Obviously, libcurl means neither protocol nor feature.
Commit https://github.com/springlobby/springlobby/commit/252c4cb156c1442ed9b4faec3f26265bc7c295ff fixes this call to
FIND_PACKAGE(CURL REQUIRED)
The Springlobby 0.268 supports the older lobby servers with most players on it as well as the newer ones.
So in case you want to compile and use the older 0.268 Springlobby, you have to git clone the current version like I already wrote and then cherry pick the older version by:
git checkout 0.268
Apply the posted fix by Tsyvarev in src/CMakeLists.txt, line 127. But you also have to add:
#include <string>
to the files src/battlelist.h and src/utils/sortutil.h below the includes at the top of these files.

Running configure file in MinGW64: default build_alias command and default prefix not found

I'm using MinGW64 via an MSYS2 download and am currently trying to install the Solar Geometry 2 library (http://www.oie.mines-paristech.fr/Valorisation/Outils/Solar-Geometry/) for use. I'm following their install README, which states to navigate to the directory and "configure" (I've been typing "./configure". However, when I do so, I get the following message in my terminal:
$ ./configure
configure: loading site script /mingw64/etc/config.site
/mingw64/etc/config.site: line 13: config.site:13: default build_alias set to x6_64-w64-mingw32: command not found
/mingw64/etc/config.site: line 20: config.site:20: default prefix set to /mingw4: No such file or directory
configure: error: cannot find install-sh or install.sh in . ./.. ./../..
When I initially installed MSYS2 I set up the etc/fstab file as recommended. However, I'm quite new to MSYS so I'm assuming I botched something in my setup. I haven't edited anything in the config.site file mentioned in the errors, so I'm wondering if it's something in there.
Any help is greatly appreciated, thank you
No where in the directions for "Solar Geometry" do I see reference to MSys or MSys2.
I suggest you install the compiler toolchain and base development file. No idea if you editing /etc/fstab will cause problems. I do not normmaly edit it!
Install MinGW Package build packages. You might need more packages installed.
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

Unable to install Anaconda environment containing anaconda 4.0.0 np110py27_0

In Anaconda I am trying to create an environment using an environment.yml file which begins with the lines:
name: mytest
dependencies:
- anaconda=4.0.0=np110py27_0
However when trying to create the environment, I get the error:
Fetching package metadata .........
Solving package specifications: ....
Error: The following specifications were found to be in conflict:
- anaconda 4.0.0 np110py27_0
Use "conda info <package>" to see the dependencies for each package.
I encountered no problems when I did this seven days ago, but when I tried this yesterday I got the error.
I am running on Windows 7 64-bit as administrator, Anaconda 2.2.0 (Python 2.7 version). The "conda list" output includes conda 4.1.11 and conda-env 2.5.2.
To try to isolate the error, I installed Miniconda2 on a different 64-bit Windows 7 computer (as administrator) that had never had any Anaconda/Miniconda installed before. This is the most recent 64-bit Python 2.7 series (Miniconda2-4.1.11-Windows-x86_64.exe).
But trying to install anaconda=4.0.0=np110py27_0, either to a new environment or to the root environment, both produce the same error I received before:
C:\>conda install anaconda=4.0.0=np110py27_0
Fetching package metadata .........
.Solving package specifications: ....
The following specifications were found to be in conflict:
- anaconda 4.0.0 np110py27_0
Use "conda info <package>" to see the dependencies for each package.
C:\>conda create --name test400 anaconda=4.0.0=np110py27_0
Fetching package metadata .........
.Solving package specifications: ....
The following specifications were found to be in conflict:
- anaconda 4.0.0 np110py27_0
Use "conda info <package>" to see the dependencies for each package.
How can I determine what is causing the conflict, and how could I resolve it, given that conda is not naming a second package in its error message? I have seen responses to other "specifications in conflict" questions in which the answer is often "Install the problematic package to a separate python environment", but in this case the new environment could not be created with the package. Starting from a clean Miniconda install did not work either. I suspect something has changed in the Anaconda repository (which would be consistent with the original environment.yml working in the past but not now), but how would I determine if this is the underlying issue?
Thanks.
The underlying issue was a temporary error in the https://repo.continuum.io/pkgs/free/win-64/repodata.json file, which has since been fixed.
For reference for anyone investigating Anaconda dependency conflicts, here are the details of the investigation, and the workaround for this case:
The cause:
The repodata.json file (linked above) is essentially a 'master list' of the dependencies of the various libraries in https://repo.continuum.io/pkgs/free/win-64/. The "conda" command uses this repodata.json file.
While the problem was occurring, the repodata.json file incorrectly listed "_nb_ext_conf" as a dependency for each version of ipywidgets. (The /info/index.json file inside "ipywidgets-4.1.1-py27_0.tar.bz2" did not list "_nb_ext_conf" as a dependency, however I think newer versions of ipywidgets require it.)
The "_nb_ext_conf-0.2.0-py27_0.tar.bz2" and "_nb_ext_conf-0.3.0-py27_0.tar.bz2" files list "notebook >=4.2.0" as a dependency in their info/index.json files.
The info/index.json file in anaconda-4.0.0-np110py27_0.tar.bz2 file (which is used when you specify "anaconda=4.0.0=np110py27_0" in an environment.yml) lists "ipywidgets 4.1.1 py27_0" as a dependency.
Due to the temporary problem in repodata.json, this "ipywidgets 4.1.1 py27_0" caused conda to think "_nb_ext_conf" needed to be installed, thus causing conda to think "notebook >=4.2.0" also needed to be installed.
But the info/index.json file in anaconda-4.0.0-np110py27_0.tar.bz2 file also specifies that the specific version "notebook 4.1.0 py27_2" must be installed.
The conflicting requirements for "notebook" versions (4.1.0 and >=4.2.0) caused the "specifications were found to be in conflict" error.
The workaround:
First, remove the line "- anaconda=4.0.0=np110py27_0" from the environment.yml file.
Next, replace that line in environment.yml with every library listed in the "depends" section of the info/index.json file from anaconda-4.0.0-np110py27_0.tar.bz2. (Remove the quotation marks, replace the spaces with equals signs, etc. to convert the .json syntax to the environment.yml syntax.)
Finally, remove the "- notebook=4.1.0=py27_2" line from this list.
This new environment.yml file will now list every library which would have been installed by "anaconda=4.0.0=np110py27_0", with the exception of "notebook", but "notebook" will get installed anyway due to the "notebook >=4.2.0" requirement in "_nb_ext_conf" due to "ipywidgets", and/or the "notebook" requirement in "ipywidgets" itself.
Investigative tools:
The command "conda info anaconda=4.0.0=np110py27_0" gives the list of libraries required by the specified package, according to repodata.json. I put this list of libraries into a temporary_environment.yml file. Attempting to create an environment from that temporary_environment.yml file caused conda to specify that "notebook" was involved in the conflict, which gave the hint to try omitting "notebook".
Running "conda info" lists all the libraries currently installed in the active environment. The output for the environment created by temporary_environment.yml was compared to the output from an environment from a computer where "anaconda=4.0.0=np110py27_0" had previously installed successfully. This highlighted "_nb_ext_conf" as one difference.
I created a batch file which ran "conda info" for every library listed in anaconda=4.0.0=np110py27_0, and I looked for instances of "notebook" and "_nb_ext_conf" in the output. This pointed to "ipywidgets" as a suspect.