ISSM configuration and compilation

Compiling MEX Files on macOS with the Command Line Tools

Many Mac users prefer to install just the Command Line Tools and not the full Xcode application due to its size and because they are not developing apps for Apple operating systems. This can cause an issue in some cases where MEX files cannot be compiled out of the box. Essentially, the Xcode license has to be accepted before its compilers can be used, but there is no Xcode to start up! This can be fixed by running,

VER=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables); defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense ${VER}

in a terminal. NOTE: This will need to be done for each user on the machine that will be compiling MEX files.

configure: error: Couldn't find mex... check your installation of matlab

This error message typically happens on Macs, because MATLAB does not support XCode7.0. MATLAB provides a patch available here.

If this fix does not work, you can do the following maneuver manually. In MATLAB, open the xml file that specifies where the SDK is located:

edit ([matlabroot '/bin/maci64/mexopts/clang++_maci64.xml'])

Toward the bottom, you will see a line that look like this, referencing "10.10":

<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk" />

Copy and paste this line (immediately after the first) and change the second one to "10.11", like this:

<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk" /> <dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk" />

Do this against for another instance in this file, both must be modified. This should allow you to link against the OS X 10.11 SDK, but please be aware that this is configuration that has not been validated by MathWorks.

If you want to check that mex is now working, you can try to compile the following file:

#include <mex.h> void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){}

Let's call this file conftest.cpp. You can compile it using:

mex conftest.cpp

If it fails, your mex compiler is still not working, please contact MATLAB support and send them this file.

MATLAB MEX compile error

In file included from /Applications/MATLAB_R2013a.app/extern/include/mex.h:58: In file included from /Applications/MATLAB_R2013a.app/extern/include/matrix.h:294: /Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t' typedef char16_t CHAR16_T;

This happens after an upgrade of XCode, which also upgraded the C/C++ compiler, which MATLAB is not aware of. Add the following line to $ISSM_DIR/configure.sh

export CXXFLAGS=" -std=c++11"

Reconfigure and recompile.

Missing gfortran symbol

If you get the following error message:

CXX main/issm_slr-issm_slr.o CXX main/kriging-kriging.o CXXLD issm.exe /bin/ld: ./.libs/libISSMCore.so: undefined reference to symbol '_gfortran_transfer_real_write@@GFORTRAN_1.4' //usr/lib64/libgfortran.so.3: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

This is because you need to tell ISSM where your gfortran library is located. One way to do this is to do:

$mpif77 -print-file-name="libgfortran.a"

This will return the path to the gfortran library that was used to compile mpich and PETSc. If, for example, you get:

$/usr/lib/gcc/x86_64-linux-gnu/7/libgfortran.a

The path to the gfortran library in this case is /usr/lib/gcc/x86_64-linux-gnu/7/. In your configuration script, you should add the following line:

--with-fortran-lib="/usr/lib/gcc/x86_64-linux-gnu/7/ -lgfortran" \

You can then reconfigure and recompile ISSM:

$ ./configure.sh $ make $ make install

*** No rule to make target

If you get the following error message:

make[3]: *** No rule to make target `objects/Gauss/GaussTria.cpp', needed by `libISSMCore_a-GaussTria.o'. Stop. make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2

This is because you just updated ISSM and you need to clean the trunk:

$ cd $ISSM_DIR $ make distclean

and then you will need to reconfigure:

$ cd $ISSM_DIR $ ./scripts/automakererun.sh

ISSM can then be configured for the given OS. Several scripts exist to configure ISSM, they are all located in $ISSM_DIR/configs. Users should use the configuration script that is the closest to their environment. The configuration file must be copied in $ISSM_DIR and executed:

$ ./configure.sh $ make $ make install

Error message when compiling, with unresolved symbols in PETSc

The issue may lie with the external package PETSc, which you should compile with shared libraries enabled. Otherwise, at run time, on some platforms, python will not be able to resolve the PETSc symbols using statically compiled PETSc's libraries.

Linkage Error for drand48 and srand48 specifications in Windows

c:\issmuci\trunk-jpl\externalpackages\petsc\install\include\petscfix.h(12) : error C2732: linkage specification contradicts earlier specification for 'drand48' c:\issmuci\trunk-jpl\externalpackages\petsc\install\include\petscfix.h(12) : see declaration of 'drand48' c:\issmuci\trunk-jpl\externalpackages\petsc\install\include\petscfix.h(13) : error C2732: linkage specification contradicts earlier specification for 'srand48' c:\issmuci\trunk-jpl\externalpackages\petsc\install\include\petscfix.h(13) : see declaration of 'srand48'

This error message indicates that PETSc is not linking properly with your issm due to a C-specific definition in a header file. The petsc header file needs to be patched. Open $ISSM_DIR/externalpackages/petsc/install/include/petscfix.h, and edit the file by commenting out lines 10 and 14 like so:

10 //extern "C" { 11 int getdomainname(char *, int); 12 double drand48(); 13 void srand48(long); 14 //}

wget: symbol lookup error

If you get the following error message,

wget: symbol lookup error: wget: undefined symbol: psl_str_to_utf8lower

when running an external package's installation script, it is likely due to the fact that you have installed GMT (for example, for a build that features Dakota) and then run:

source $ISSM_DIR/etc/environment.sh

What is happeneing here is that GMT has its own copy of libpsl and wget is loading it rather than the system copy. One way to get around this is to simply open a new terminal, do not run

source $ISSM_DIR/etc/environment.sh

then try to install the external package again,

X11 Library not found

g++: /usr/lib64/libX11.so: No such file or directory

This error message indicates that your X11 library is not located in /usr/lib64/libX11.so, which is the location that was provided in the ISSM configuration script (configure.sh). You need to find where this library is located and change the path in the configuration script:

--with-graphics-lib="/usr/lib/x86_64-linux-gnu/libX11.so"

MPICH2 linking error

/trunk/externalpackages/mpich2/install/lib//libmpich.a(init.o): In function `MPI_Init': init.c:(.text+0x48): undefined reference to `MPL_env2str' init.c:(.text+0x93): undefined reference to `MPL_env2bool'

This error message indicates that you are using mpich2 version higher than 1.3, and that -lmpl is missing in -with-mpi-lib=. Edit your ISSM configuration script (configure.sh) and change the corresponding line to:

--with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich -lmpl"