Cmake error while installing Pygplates

Hi,
I’m trying to install pygplates on Ubuntu 18.04. I’ve installed all the dependencies following dep.linux.

I’m getting the following error when I run cmake. Something to do with Boost lib.

I’m not sure how to resolve this issue. Any leads would be really helpful.

Thanks.

It seems the cmake found Boost 1.35 in the system folder, but it is using the boost-1.74.0 BoostConfig.cmake from conda env “pygmt”. If you need to use pygplates in your conda env, you need to force cmake to use the boost-1.74.0

Hi Harsha,

It looks like you have activated a conda environment (that you’ve name pygmt).

Did you install the dependencies as Ubuntu packages or using conda? I’m assuming the former since you mention the DEPS.Linux file which only covers the former. If not, then it’s best to install the dependencies using conda (when you’ve activated a conda environment).

Here are the steps I’ve used to build pygplates using conda dependencies:

Firstly I add the conda-forge channel and force the use of only conda-forge with strict channel priority (all pygplates dependencies are available on conda-forge, so this prevents mixing of channels).

conda config --add channels conda-forge
conda config --set channel_priority strict

Then I created a conda environment called pygplates_py38 to build pygplates with:

conda create --name pygplates_py38 python=3.8

…in your case your environment is called pygmt.

Then I activate the pygplates_py38 conda environment:

conda activate pygplates_py38

Then I install the pygplates dependencies:

conda install qt qwt cgal gdal boost proj zlib glew

Update: Also install cmake with conda install cmake. As noted in the post below this is needed on Ubuntu 18.04 (but was not needed on 20.04), but it’s a good idea to do this anyway.

Then I configure pygplates for compilation but instead of running cmake . as usual, I run:

cmake -DCMAKE_PREFIX_PATH:PATH=~/miniconda3/envs/pygplates_py38 .

…where ~/miniconda3 is where I installed MiniConda3 (the default location). The CMAKE_PREFIX_PATH tells CMake to look for dependencies in the conda environment first before looking in the standard Ubuntu system locations.

Then I compile pygplates:

make pygplates

Then I set the PYTHONPATH environment to the location of the pygplates.so just built (it’s in the bin sub-directory, but you can copy it elsewhere). Then when I run python in my activated environment I can then import pygplates.

By the way, we should have a conda package available for the next pyGPlates release so that you don’t need to install the dependencies or compile pygplates, instead just running conda install pygplates.

@mchin I’m not sure how to force CMake to use boost-1.74.0. Can you please tell me how to do it?

@thor524

Please see @john.cannon 's reply above. I think the key is cmake -DCMAKE_PREFIX_PATH:PATH=~/miniconda3/envs/pygplates_py38 .. And you need to install all the dependencies in your conda env “pygmt”. See john’s reply for details.

Alternatively, you can use conda build . -c conda-forge. See the recipe/meta.yaml below.


package:
  name: pygplates
  version: 2.1
  
source:
  path: ../

build:
  number: 0

requirements:
  build:
    - cmake
    - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('libx11-devel') }}          # [linux]
    - {{ cdt('libxext-devel') }}         # [linux]
    - {{ cdt('libxrender-devel') }}      # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('mesa-libegl-devel') }}     # [linux]
    - {{ cdt('mesa-dri-drivers') }}      # [linux]
    - {{ cdt('libxau-devel') }}          # [linux]
    - {{ cdt('libdrm-devel') }}          # [linux]
    - {{ cdt('libxcomposite-devel') }}   # [linux]
    - {{ cdt('libxcursor-devel') }}      # [linux]
    - {{ cdt('libxi-devel') }}           # [linux]
    - {{ cdt('libxrandr-devel') }}       # [linux]
    - {{ cdt('libxscrnsaver-devel') }}   # [linux]
    - {{ cdt('libxtst-devel') }}         # [linux]
    - {{ cdt('libselinux-devel') }}      # [linux]
    - cgal
    - glew
    - python
    - qt
    - boost
    - gdal
    - proj
    - qwt
    - zlib
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
  host:
    - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('libx11-devel') }}          # [linux]
    - {{ cdt('libxext-devel') }}         # [linux]
    - {{ cdt('libxrender-devel') }}      # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('mesa-libegl-devel') }}     # [linux]
    - {{ cdt('mesa-dri-drivers') }}      # [linux]
    - {{ cdt('libxau-devel') }}          # [linux]
    - {{ cdt('libdrm-devel') }}          # [linux]
    - {{ cdt('libxcomposite-devel') }}   # [linux]
    - {{ cdt('libxcursor-devel') }}      # [linux]
    - {{ cdt('libxi-devel') }}           # [linux]
    - {{ cdt('libxrandr-devel') }}       # [linux]
    - {{ cdt('libxscrnsaver-devel') }}   # [linux]
    - {{ cdt('libxtst-devel') }}         # [linux]
    - {{ cdt('libselinux-devel') }}      # [linux]
    - cgal
    - glew
    - python
    - qt
    - boost
    - gdal
    - proj
    - qwt
    - zlib
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
  run:
    - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('libx11-devel') }}          # [linux]
    - {{ cdt('libxext-devel') }}         # [linux]
    - {{ cdt('libxrender-devel') }}      # [linux]
    - {{ cdt('mesa-libgl-devel') }}      # [linux]
    - {{ cdt('mesa-libegl-devel') }}     # [linux]
    - {{ cdt('mesa-dri-drivers') }}      # [linux]
    - {{ cdt('libxau-devel') }}          # [linux]
    - {{ cdt('libdrm-devel') }}          # [linux]
    - {{ cdt('libxcomposite-devel') }}   # [linux]
    - {{ cdt('libxcursor-devel') }}      # [linux]
    - {{ cdt('libxi-devel') }}           # [linux]
    - {{ cdt('libxrandr-devel') }}       # [linux]
    - {{ cdt('libxscrnsaver-devel') }}   # [linux]
    - {{ cdt('libxtst-devel') }}         # [linux]
    - {{ cdt('libselinux-devel') }}      # [linux]
    - cgal
    - glew
    - python
    - qt
    - boost
    - gdal
    - proj
    - qwt
    - zlib
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}

about:
  summary: ''
  description: ''

extra:
  recipe-maintainers:
    - mc

@john.cannon Thanks for the detailed steps. I created a new environment and followed the steps you mentioned. Still, I get the boost error while running cmake.

Any suggestions?

@mchin I did try @john.cannon steps by creating a new conda envornment. But still the same boost error.

It’s getting a bit further this time, it’s finding conda’s version of boost now (but only the boost headers, not the libraries).

I had this working on Ubuntu 20.04, but I’ll try Ubuntu 18.04 (same as you) and see if I can reproduce this.

One thing you can try in the meantime is to also install cmake via conda (conda install cmake) and then run cmake again - I don’t anticipate this’ll make too much difference but worth a try.

And as Michael noted, the CMAKE_PREFIX_PATH is how we’re currently forcing CMake to use the dependencies from conda (instead of the system).

I think now the python version messed up. According to your conda env name, you are using python38. but somehow cmake is trying to find boost_python36. I guess you need to check the python versions in your conda env. And maybe you can try to check CMakeCache.txt file and see which python has been found.

If you want, you can try conda build. I think it is less problematic.

Copy the “recipe” folder into pygplates source code and follow the instructions in the README.MD.

https://www.earthbyte.org/webdav/ftp/incoming/mchin/pygplates-conda-build.zip

1 Like

@thor524

I had built a conda package a couple months ago. If you like, you can download the package and use conda to install the local package. You need python37 env. See the README.MD in https://www.earthbyte.org/webdav/ftp/incoming/mchin/pygplates-conda-build.zip

Download the conda package here (THIS IS NOT OFFICIAL BUILD. IT IS JUST MY TEST BUILD!!!)
https://www.earthbyte.org/webdav/ftp/incoming/mchin/pygplates-2.1-py37hf484d3e_0.tar.bz2

@mchin…Thanks for the build. Installing it now. Will update you once it’s done.

Actually installing conda’s cmake worked for me. Prior to that (on Ubuntu 18.04, same as you) I got the following error. I think it’s because the version of the system cmake is only 3.10 whereas conda’s cmake is 3.21 (and so it’s builtin FindBoost script has more bug fixes).

CMake Error at /home/gplates/miniconda3/envs/pygplates_py38/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package):
  Could not find a package configuration file provided by "boost_python3"
  (requested version 1.72.0) with any of the following names:

    boost_python3Config.cmake
    boost_python3-config.cmake

  Add the installation prefix of "boost_python3" to CMAKE_PREFIX_PATH or set
  "boost_python3_DIR" to a directory containing one of the above files.  If
  "boost_python3" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /home/gplates/miniconda3/envs/pygplates_py38/lib/cmake/Boost-1.72.0/BoostConfig.cmake:185 (boost_find_component)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:242 (find_package)
  src/CMakeLists.txt:221 (find_package)

@john.cannon That’s exactly the same error I got before. Let me try installing conda cmake and see if it worked.

Thanks

@john.cannon @mchin Thanks for all the help. Install cmake using conda finally did the trick!!!

I’ve discovered a few issues with the pygplates source (in the last public release) when using conda. Here are the fixes:

  1. Was finding the system qwt instead of conda’s qwt:
    To fix this, edit cmake/modules/FindQwt.cmake and insert NAMES_PER_DIR as shown below (but without the + sign):
     find_library(QWT_LIBRARY
       # The '-qt5' versions searched first (in case 'qwt' is a qt4 version)...
       NAMES qwt-qt5 qwt6-qt5 qwt qwt6
    +  NAMES_PER_DIR
       PATHS
         /usr/lib
         /usr/local/lib
    
  2. Was finding the system proj instead of conda’s proj
    To fix this, edit cmake/modules/FindPROJ.cmake and insert proj.h before every occurrence of proj_api.h. An example of this is shown in the diff below:
    -    FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
    +    FIND_PATH(PROJ_INCLUDE_DIR proj.h proj_api.h
    
    Without this you would get a runtime error like undefined symbol: pj_free when importing pygplates.
  3. A compile error: invalid use of incomplete type ‘class QwtText’:
    To fix this, edit src/qt-widgets/KinematicGraphPicker.h and insert #include "qwt_text.h" as shown below (but without the + sign):
     #include "qwt_plot_canvas.h"
     #include "qwt_plot_picker.h"
    +#include "qwt_text.h"
    
    This is needed because conda upgraded qwt from 6.1 to 6.2.

I would suggest starting with a fresh install of the source code you have (ie, delete your current source code directory and extract it again). Then try the above edits. And then run cmake and make, as before. Once I did this I was able to successfully compile pygplates with conda and import it into conda’s Python.

These fixes are in the latest development source code (and will be available in the next public release).

Running the conda-build script might have similar problems because it is essentially building in the same way - which is why we will be providing a conda package for pygplates for the next public release (along the lines of Michael’s test build) so that users don’t have to go through this.

@john.cannon make pygplates failed and was giving me some errors. I’m going to make the changes you suggested and try it again

@john.cannon I was able to successfully build and install pygplates. Thanks