Skip to content

Building on OSX and testing examples/pbsam-barn_bars #298

@mihaitodor

Description

@mihaitodor

Describe the bug

I tried to build apbs and test it with the existing pbsam-barn_bars example. However, it crashes with the following error:

libc++abi: terminating due to uncaught exception of type pbsolvers::CouldNotReadException: Could not read:
zsh: abort      apbs barn_bars_electro.in

To Reproduce
Steps to reproduce the behavior:

Use the following build script:

#!/usr/bin/env bash

# Ideally we should let CMake download and build the right version, but that seems to be broken.
# Due to this, we need to make sure that only Eigen 3 is installed, so CMake can detect and use it correctly.
if brew uninstall eigen 2>&1 >/dev/null | grep -v 'No such keg'; then
    echo "Can't uninstall eigen because other packages depend on it."
    exit 1
fi

brew install \
    bison \
    flex \
    swig \
    boost \
    eigen@3 \
    lapack \
    suite-sparse \
    openblas \
    superlu \
    cmake \
    gcc \
    libomp \
    python@3.10

brew link eigen@3

apbs_dir="$(pwd)/apbs"

if [ ! -d ${apbs_dir} ]; then
    git clone https://github.com/Electrostatics/apbs.git
fi

cd ${apbs_dir}

python3.10 -m venv .venv
source .venv/bin/activate
pip install cmake==3.31.6

export INSTALL_DIR=$(pwd)/dist
mkdir -p ${INSTALL_DIR}

deps_dir="${apbs_dir}/deps"
mkdir -p ${deps_dir}

cd ${deps_dir}
if [ ! -d "metis-5.1.0" ]; then
    git clone https://github.com/Electrostatics/metis-fork.git metis-5.1.0
    cd metis-5.1.0
    mkdir -p build && cd build
    cmake -DCMAKE_VERBOSE_MAKEFILE=1 -DGKLIB_PATH=../GKlib -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ..
    make install
fi

cd ${deps_dir}
if [ ! -d "arpack-ng" ]; then
    git clone https://github.com/opencollab/arpack-ng.git
    cd arpack-ng
    git fetch --all --tags
    git checkout tags/3.8.0 -b latest
    mkdir build && cd build
    cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_BUILD_TYPE=Release -DEXAMPLES=OFF -DMPI=OFF -DBUILD_SHARED_LIBS=OFF ..
    make install
fi

cd ${apbs_dir}
export CMAKE_PREFIX_PATH="${INSTALL_DIR}:$(brew --prefix openblas):$(brew --prefix libomp)"
export CMAKE_C_FLAGS="-I${INSTALL_DIR}/include -Wno-incompatible-function-pointer-types -Wno-implicit-int"
export CMAKE_CXX_FLAGS="-I${INSTALL_DIR}/include"
export BLAS_LIBRARIES="$(brew --prefix openblas)/lib/libopenblas.dylib"
export ENABLE_OPENMP=OFF
export ENABLE_PBAM=ON
export ENABLE_PBSAM=ON
export ENABLE_PYTHON=ON
# export PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
# export PYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
./.build.sh

if [ -f ./dist/bin/apbs ]; then
    echo "All done!"
    echo "Please add the following to your shell environment:"
    echo "export PATH=${INSTALL_DIR}/bin:${INSTALL_DIR}/share/apbs/tools/bin:\${PATH}"
fi

Then run this:

$ cd examples/pbsam-barn_bars
$ apbs barn_bars_electro.in

Since apbs first failed with Error! APBS not compiled with PBSAM! when running the pbsam-barn_bars example, I set ENABLE_PBSAM=ON (and also ENABLE_PBAM=ON, but I'm not sure if that's needed). However, this produced a compilation error: src/generic/vparam.h:69:10: fatal error: 'mc/mc.h' file not found. I'm no CMake expert, but I was able to work around this by patching CMakeLists.txt (not sure if there's a nicer way to get fetk to install in a custom $INSTALL_DIR):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46a0a50..1b85e59 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,6 +170,13 @@ set(FETK_VERSION "57195e55351e04ce6ee0ef56a143c996a9aee7e2" CACHE STRING "Versio
 include(ImportFETK)
 import_fetk(${FETK_VERSION})

+if(EXISTS "${fetk_BINARY_DIR}/cmake_install.cmake")
+    add_custom_target(fetk-install ALL
+        COMMAND ${CMAKE_COMMAND} --build ${fetk_BINARY_DIR} --target install
+        COMMENT "Installing FETK into dist directory"
+    )
+endif()
+

 ###############################################################################
 ##  NOTE: For Debugging and generally nice information to have

Expected behavior

No error should be emitted.

Desktop (please complete the following information):

  • OS: Sequoia 15.7.1
  • Version: Latest main commit 4613d0d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions