Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find catch2 include files during pylith-installer build #79

Open
EvanKDodge opened this issue Sep 17, 2024 · 20 comments
Open

Comments

@EvanKDodge
Copy link

Hello,

I'm having an issue getting pylith-installer (4.1.3) to work. I'm trying to get it built on a cluster (Pleiades at NASA) using our installed MPI (HPE MPT). I'm having pylith-installer build pretty much everything else. However, I keep running into an issue where it can't find the catch2 include files during the pythia build:

/usr/bin/mkdir -p pythia-build
cd pythia-build &&
CFLAGS="-g -O2" CXXFLAGS="-g -O2 -DMPICH_IGNORE_CXX_SEEK" FCFLAGS="" CC=mpicc CXX=mpicxx ../pythia-1.1.0/configure --enable-testing
--prefix=/home/hexboy/local/pylith ;
make &&
make install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether mpicc accepts -g... yes
checking for mpicc option to enable C11 features... none needed
checking whether mpicc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of mpicc... gcc3
checking whether the compiler supports GNU C++... yes
checking whether mpicxx accepts -g... yes
checking for mpicxx option to enable C++11 features... none needed
checking dependency style of mpicxx... gcc3
checking for library containing MPI_Init... none required
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for mpi.h... yes
checking whether mpicxx supports C++14 features with -std=gnu++14... yes
checking for a Python interpreter with version >= 3.8... python
checking for python... /home/hexboy/local/pylith/bin/python
checking for python version... 3.10
checking for python platform... linux
checking for GNU default python prefix... ${prefix}
checking for GNU default python exec_prefix... ${exec_prefix}
checking for python script directory (pythondir)... ${PYTHON_PREFIX}/lib/python3.10/site-packages
checking for python extension module directory (pyexecdir)... ${PYTHON_EXEC_PREFIX}/lib/python3.10/site-packages
checking python sysconfig... ok
checking for python include directory... /home/hexboy/local/pylith/include/python3.10
checking for Python.h... yes
checking python config... ok
checking whether -lpython3.10 is a shared library... yes
checking how to run the C++ preprocessor... mpicxx -std=gnu++14 -E
checking for catch2/catch_test_macros.hpp... no
configure: error: Catch2 header not found; try --with-catch2-incdir=
make[3]: Entering directory '/home/hexboy/code/pylith/build/cig/pythia-build'
make[3]: *** No targets specified and no makefile found. Stop.
make[3]: Leaving directory '/home/hexboy/code/pylith/build/cig/pythia-build'
make[2]: *** [Makefile:721: pythia] Error 2
make[2]: Leaving directory '/home/hexboy/code/pylith/build/cig'
make[1]: *** [Makefile:735: installed_pythia] Error 2
make[1]: Leaving directory '/home/hexboy/code/pylith/build/cig'
make: *** [Makefile:562: all-recursive] Error 1

I've also tried on my Linux laptop. I installed MPICH and tried the same build. I ran into exactly the same error. I've also tried pylith-installer 4.1.2 and ran into the same problem. In the output above, it suggests using --with-catch2-incdir=<Catch2 include dir> in the command line. I've tried that as well with no success.

Here is my current build script:

#!/bin/bash

if [ ! -d pylith ]; then
    mkdir pylith
fi

cd pylith

if [ ! -d pylith-installer-4.1.3-0 ]; then
    tar -xvf ../../tarfiles/pylith-installer-4.1.3-0.tar.gz
fi

module purge
module load mpi-hpe/mpt

if [ ! -d build ]; then
    mkdir build
fi

cd build

../pylith-installer-4.1.3-0/configure --with-catch2-incdir=/swbuild/ekdodge/local/pylith/include --prefix=/swbuild/ekdodge/local/pylith --enable-python --enable-curl

source setup.sh
make

I am deleting the pylith build directory and install directory before each test.

Has anyone run into this before? Can anyone tell me if I've made mistakes in the above script?

@baagaard-usgs
Copy link
Contributor

What does the config.log show when it looks for the Catch2 header? It shows the exact commands being run and often provides more insight than the error message.

@EvanKDodge
Copy link
Author

Here's the relevant section of config.log:

configure:6904: checking for catch2/catch_test_macros.hpp
 #include <catch2/catch_test_macros.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
configure:6904: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "pythia"
| #define PACKAGE_TARNAME "pythia"
| #define PACKAGE_VERSION "1.1.0"
| #define PACKAGE_STRING "pythia 1.1.0"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL ""
| #define PACKAGE "pythia"
| #define VERSION "1.1.0"
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define STDC_HEADERS 1
| #define HAVE_CXX14 1
| /* end confdefs.h.  */
| #include <stddef.h>
| #ifdef HAVE_STDIO_H
| # include <stdio.h>
| #endif
| #ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| #endif
| #ifdef HAVE_STRING_H
| # include <string.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| #include <catch2/catch_test_macros.hpp>
configure:6904: result: no
configure:6910: error: Catch2 header not found; try --with-catch2-incdir=<Catch2 include dir>

@baagaard-usgs
Copy link
Contributor

I don't see the compilation line at the top of the test. For example, when I build the binary using the installer, config.log contains the following:

configure:6904: checking for catch2/catch_test_macros.hpp
configure:6904: mpicxx -std=gnu++14 -c -mmacos-version-min=11.0 -DMPICH_IGNORE_CXX_SEEK   conftest.cpp >&5
configure:6904: $? = 0
configure:6904: result: yes
configure:6929: checking for REQUIRE() in -lCatch2
configure:6942: mpicxx -std=gnu++14 -o conftest -mmacos-version-min=11.0 -DMPICH_IGNORE_CXX_SEEK   -L/scratch/build/clang-15.0/cig/pylith-binary-arm64
/dist/lib -mmacos-version-min=11.0  conftest.cpp -lCatch2 >&5
configure:6942: $? = 0
configure:6944: result: yes

Are you installing the dependencies like Catch2 manually or having the installer build them? It is usually easier to have the installer install everything that does not need specific settings for your hardware. For example, you can use --enable-catch2 when running the installer configure to have the installer build and install Catch2.

@EvanKDodge
Copy link
Author

Sorry. Here's the very top:

configure:6904: checking for catch2/catch_test_macros.hpp
configure:6904: mpicxx -std=gnu++14 -c -g -O2 -DMPICH_IGNORE_CXX_SEEK   conftest.cpp >&5
conftest.cpp:50:10: fatal error: catch2/catch_test_macros.hpp: No such file or directory
 #include <catch2/catch_test_macros.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
configure:6904: $? = 1
configure: failed program was:

Neither of the systems that I ran the build on have catch2 installed so catch2 is indeed being built. I see it in the build directory and I see it in the install directory as well (I also see all of the include files in there as well). Everything is here, I'm just not sure why pythia can't find it.

@baagaard-usgs
Copy link
Contributor

I was able to dig deeper into the PyLith installer build and I think I see the problem. The Pythia configure wasn't using the Catch2 settings passed to configure or the default CPPFLAGS. I pushed a fix to https://github.com/baagaard-usgs/pylith_installer/tree/fix-pythia-build-flags. Can you checkout that branch and try building again? You will need to run autoreconf -if in the installer source directory to generate the configure script.

@EvanKDodge
Copy link
Author

I'm getting this when I run autoreconf -if:

libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, './aux-config'.
libtoolize: copying file './aux-config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:704: error: possibly undefined macro: AC_PROG_SWIG
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

This could very well be a config issue on my end, but I also don't have a lot of experience with autoconf. Here is the script I'm currently using. Please let me know if you see any issues:

#!/bin/bash

if [ ! -d pylith ]; then
    mkdir pylith
fi

cd pylith

if [ ! -d pylith_installer ]; then
    git clone https://github.com/baagaard-usgs/pylith_installer
    cd pylith_installer
    autoreconf -if
    cd ..
fi

module purge
module load mpi-hpe/mpt

if [ ! -d build ]; then
    mkdir build
fi

cd build

../pylith_installer/configure --with-catch2-incdir=/swbuild/ekdodge/local/pylith/include --prefix=/swbuild/ekdodge/local/pylith --enable-python --enable-curl

source setup.sh
make

@baagaard-usgs
Copy link
Contributor

When you clone the repo you need to use the --recursive flag so that it also clones the submodule repositories.

@EvanKDodge
Copy link
Author

Now it's looking for cpp-unit include files:

/usr/bin/mkdir -p pythia-build
cd pythia-build && \
	../pythia-1.0.0/configure --enable-testing \
		--prefix=/swbuild/ekdodge/local/pylith CFLAGS="-g -O2" CXXFLAGS="-g -O2 -DMPICH_IGNORE_CXX_SEEK" FCFLAGS="" CC=mpicc CXX=mpicxx; \
	make && \
	make install && \
	touch /swbuild/ekdodge/TOSS4_builds/pylith/build/cig/installed_pythia
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether mpicc accepts -g... yes
checking for mpicc option to accept ISO C89... none needed
checking whether mpicc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of mpicc... gcc3
checking whether we are using the GNU C++ compiler... yes
checking whether mpicxx accepts -g... yes
checking dependency style of mpicxx... gcc3
checking for library containing MPI_Init... none required
checking how to run the C preprocessor... mpicc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mpi.h usability... yes
checking mpi.h presence... yes
checking for mpi.h... yes
checking whether mpicxx supports C++11 features with -std=gnu++11... yes
checking for a Python interpreter with version >= 3.6... python
checking for python... /swbuild/ekdodge/local/pylith/bin/python
checking for python version... 3.10
checking for python prefix... /swbuild/ekdodge/local/pylith
checking for python exec_prefix... /swbuild/ekdodge/local/pylith
checking for python platform... linux
checking for python script directory... ${PYTHON_PREFIX}/lib/python3.10/site-packages
checking for python extension module directory... ${PYTHON_EXEC_PREFIX}/lib/python3.10/site-packages
checking python sysconfig... ok
checking for python include directory... /swbuild/ekdodge/local/pylith/include/python3.10
checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking python config... ok
checking whether -lpython3.10 is a shared library... yes
checking how to run the C++ preprocessor... mpicxx -std=gnu++11 -E
checking cppunit/TestRunner.h usability... no
checking cppunit/TestRunner.h presence... no
checking for cppunit/TestRunner.h... no
configure: error: CppUnit header not found; try --with-cppunit-incdir=<CppUnit include dir>
make[3]: Entering directory '/vast_swbuild/swbuild/ekdodge/TOSS4_builds/pylith/build/cig/pythia-build'
make[3]: *** No targets specified and no makefile found.  Stop.
make[3]: Leaving directory '/vast_swbuild/swbuild/ekdodge/TOSS4_builds/pylith/build/cig/pythia-build'
make[2]: *** [Makefile:740: pythia] Error 2
make[2]: Leaving directory '/vast_swbuild/swbuild/ekdodge/TOSS4_builds/pylith/build/cig'
make[1]: *** [Makefile:751: installed_pythia] Error 2
make[1]: Leaving directory '/vast_swbuild/swbuild/ekdodge/TOSS4_builds/pylith/build/cig'
make: *** [Makefile:569: all-recursive] Error 1

Here's the error from config.log

configure:6268: result: no
configure:6268: checking cppunit/TestRunner.h presence
configure:6268: mpicxx -std=gnu++11 -E   conftest.cpp
conftest.cpp:22:10: fatal error: cppunit/TestRunner.h: No such file or directory
 #include <cppunit/TestRunner.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
configure:6268: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "pythia"
| #define PACKAGE_TARNAME "pythia"
| #define PACKAGE_VERSION "1.0.0"
| #define PACKAGE_STRING "pythia 1.0.0"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL ""
| #define PACKAGE "pythia"
| #define VERSION "1.0.0"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_CXX11 1
| /* end confdefs.h.  */
| #include <cppunit/TestRunner.h>
configure:6268: result: no
configure:6268: checking for cppunit/TestRunner.h
configure:6268: result: no
configure:6273: error: CppUnit header not found; try --with-cppunit-incdir=<CppUnit include dir>

Here is my current script (I've already added --with-cppunit-incdir=... and it still fails:

#!/bin/bash

if [ ! -d pylith ]; then
    mkdir pylith
fi

cd pylith

if [ ! -d pylith_installer ]; then
    git clone --recursive https://github.com/baagaard-usgs/pylith_installer
    cd pylith_installer
    autoreconf -if
    cd ..
fi

module purge
module load mpi-hpe/mpt

if [ ! -d build ]; then
    mkdir build
fi

cd build

../pylith_installer/configure --with-cppunit-incdir=/swbuild/ekdodge/local/pylith/include --with-catch2-incdir=/swbuild/ekdodge/local/pylith/include --prefix=/swbuild/ekdodge/local/pylith --enable-python --enable-curl

source setup.sh
make

@baagaard-usgs
Copy link
Contributor

The current PyLith installer does not know about CppUnit. It only knows about Catch2. I think you cloned the wrong repository or branch. Please try the attached tarball for the installer.
pylith-installer-4.1.3-1.tar.gz

@EvanKDodge
Copy link
Author

I'm sorry. I'm running into exactly the same issue. Here's my script:

#!/bin/bash

rm -rf pylith/
rm -rf ../local/pylith

if [ ! -d pylith ]; then
    mkdir pylith
fi

cd pylith

if [ ! -d pylith-installer-4.1.3-1 ]; then
    if [ ! -e pylith-installer-4.1.3-1.tar.gz ]; then
        wget https://github.com/user-attachments/files/17037504/pylith-installer-4.1.3-1.tar.gz
    fi
    tar -xvf pylith-installer-4.1.3-1.tar.gz
fi

module purge
module load mpi-hpe/mpt

if [ ! -d build ]; then
    mkdir build
fi

cd build

../pylith-installer-4.1.3-1/configure --prefix=/vast_swbuild/swbuild/ekdodge/local/pylith --enable-python --enable-curl --with-catch2-incdir=/vast_swbuild/swbuild/ekdodge/local/pylith/include

source setup.sh
make

Same errors as before in pythia-build/config.log:

configure:6904: checking for catch2/catch_test_macros.hpp
configure:6904: mpicxx -std=gnu++14 -c -g -O2 -DMPICH_IGNORE_CXX_SEEK   conftest.cpp >&5
conftest.cpp:50:10: fatal error: catch2/catch_test_macros.hpp: No such file or directory
 #include <catch2/catch_test_macros.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
configure:6904: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "pythia"
| #define PACKAGE_TARNAME "pythia"
| #define PACKAGE_VERSION "1.1.0"
| #define PACKAGE_STRING "pythia 1.1.0"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL ""
| #define PACKAGE "pythia"
| #define VERSION "1.1.0"
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define STDC_HEADERS 1
| #define HAVE_CXX14 1
| /* end confdefs.h.  */
| #include <stddef.h>
| #ifdef HAVE_STDIO_H
| # include <stdio.h>
| #endif
| #ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| #endif
| #ifdef HAVE_STRING_H
| # include <string.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| #include <catch2/catch_test_macros.hpp>
configure:6904: result: no
configure:6910: error: Catch2 header not found; try --with-catch2-incdir=<Catch2 include dir>

@EvanKDodge
Copy link
Author

Do you see anything obvious that I'm doing wrong here?

@baagaard-usgs
Copy link
Contributor

I don't see any obvious errors in what you are doing. I suspect there is a simple error in the configure.ac + Makefile.am files, but I haven't had time to dig deeper and attempt to reproduce the error.

The simplest workaround is to have the installer build all of the dependencies needed other than the compiler and MPI rather than installing them separately. So I would include --enable-python --enable-catch2 --enable-hdf5 and so on. This is how I build the binary packages, so I know it works.

@EvanKDodge
Copy link
Author

Building all of the dependencies doesn't seem to solve the issue. It still fails with the same catch2 error. However, if I build catch2 myself and load it before I start up the pylith build, it seems to work. pythia does fail later on during testing, but I know what the issue is and it isn't related to your build. To get past this, I just want to disable testing. I've added the --with-testing=no flag to the pylith-installer configure command, but it doesn't seem to work. The tests run regardless. I can hear Inigo Montoya saying "I Do Not Think It Means What You Think It Means".

@baagaard-usgs
Copy link
Contributor

I was able to work on this some yesterday. I found a typo in my "fix" for finding the catch2 headers and libraries. I also found that the current version of spatialdata needs updated m4 macros to work with numpy v2.

In regards to turning off testing, I see that --enable-testing is erroneously hardwired in the PyLith installer configure arguments to pythia. The easiest workaround would be to just remove that from cig/Makefile.

I will fix complete fixing these issues as soon as I can (hopefully next week). Thank you for your patience and perseverance! We really appreciate it when users report issues and help us find the problems.

@EvanKDodge
Copy link
Author

Thanks very much! I'll check in next week. :)

@EvanKDodge
Copy link
Author

Hello. Just checking in to see if you've had a chance to look at these issues?

@baagaard-usgs
Copy link
Contributor

I have a set of fixes that address the problems you have identified. I am including a link to a new installer version for you to try.
https://github.com/geodynamics/pylith_installer/releases/download/v4.1.3-0/pylith-installer-4.1.3-1.tar.gz

I needed to update the spatialdata and pylith repos to use new macros for detecting the location of the numpy include files. I haven't bundled new releases yet, so the interim solution is to have the installer use Git repos rather than the release tarballs; this is done through some additional arguments to the installer. It also requires having PCRE and SWIG. Using the Git repos also adds an important fix that was in v4.1.2 but missing from v4.1.3.

Please configure with the following arguments in addition to what you need for the dependencies:

configure --enable-pcre --enable-swig --with-pylith-repo=https://github.com/baagaard-usgs/pylith.git --with-pylith-git=update-m4-macros

@EvanKDodge
Copy link
Author

Hopefully nearing the end here...

Is there any way to shut off petsc MPI testing? I'm compiling on a front-end node which does not have array services installed (which prevents users from running MPI tasks on the front-ends...which is good). If I compile on a node, MPI testing will work, but nodes don't have internet access...so you probably know how well that would work.

I'm going through the petsc documentation but I'm not seeing anything. I've checked configure -h in the cig/petsc-pylith directory as well.

@knepley
Copy link

knepley commented Oct 7, 2024

I think you might want to configure PETSc using --with-batch. This allows configure to work on a machine that cannot run anything. It makes you an executable to run on the node that writes a response that is fed back to configure. Mail [email protected] if you have any problems with the instructions that it prints.

@EvanKDodge
Copy link
Author

Thanks for the extra help! I do realize this is outside of your area of responsibility. Many thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants