Tuesday, June 7, 2022

[SOLVED] Unfamiliar with CMAKE, possible error in configuration

Issue

I am trying to install (https://github.com/NOAA-EMC/NCEPLIBS) for a post processing toolkit. I have downloaded and installed the required libraries to a build folder:

#############################Compilers#######################
    export CC=gcc
    export CXX=g++
    export FC=gfortran
    export F77=gfortran
            
    #############################zlib############################
    #Uncalling compilers due to comfigure issue with zlib1.2.12
    #With CC & CXX definied ./configure uses different compiler Flags
    cd $HOME/WRF/Downloads
    tar -xvzf v1.2.12.tar.gz
    cd zlib-1.2.12/
    CC= CXX= ./configure --prefix=$DIR/grib2
    make
    make install
    make check
     
#############################libpng###########################
    cd $HOME/WRF/Downloads
    export LDFLAGS=-L$DIR/grib2/lib
    export CPPFLAGS=-I$DIR/grib2/include
    tar -xvzf libpng-1.6.37.tar.gz
    cd libpng-1.6.37/
    ./configure --prefix=$DIR/grib2
    make
    make install
    make check
    ##############################Llibjpeg#########################
    #Used for nceplibs only
    cd $HOME/WRF/Downloads
    export LDFLAGS=-L$DIR/grib2/lib
    export CPPFLAGS=-I$DIR/grib2/include
    tar -xvzf jpegsrc.v9.tar.gz
    cd jpeg-9
    ./configure --prefix=$DIR/grib2
    make 
    make install
    #############################JasPer############################
    cd $HOME/WRF/Downloads
    unzip jasper-1.900.1.zip
    cd jasper-1.900.1/
    autoreconf -i
    ./configure --prefix=$DIR/grib2
    make
    make install
    
    export JASPERLIB=$DIR/grib2/lib
    export JASPERINC=$DIR/grib2/include
    ##############################MPICH############################
    cd $HOME/WRF/Downloads
    tar -xvzf mpich-4.0.2.tar.gz
    cd mpich-4.0.2/
    ./configure --prefix=$DIR/MPICH --with-device=ch3 FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch
    make
    make install
    make check
    
    export PATH=$DIR/MPICH/bin:$PATH
    
    #############################hdf5 library for netcdf4 functionality############################
    cd $HOME/WRF/Downloads
    tar -xvzf hdf5-1_12_2.tar.gz
    cd hdf5-hdf5-1_12_2
    ./configure --prefix=$DIR/grib2 --with-zlib=$DIR/grib2 --enable-hl --enable-fortran
    make 
    make install
    make check
    
    export HDF5=$DIR/grib2
    export LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH
    
    ##############################Install NETCDF C Library############################
    cd $HOME/WRF/Downloads
    tar -xzvf v4.8.1.tar.gz
    cd netcdf-c-4.8.1/
    export CPPFLAGS=-I$DIR/grib2/include 
    export LDFLAGS=-L$DIR/grib2/lib
    ./configure --prefix=$DIR/NETCDF --disable-dap
    make 
    make install
    make check
    
    export PATH=$DIR/NETCDF/bin:$PATH
    export NETCDF=$DIR/NETCDF
    
    ##############################NetCDF fortran library############################
    cd $HOME/WRF/Downloads
    tar -xvzf v4.5.4.tar.gz
    cd netcdf-fortran-4.5.4/
    export LD_LIBRARY_PATH=$DIR/NETCDF/lib:$LD_LIBRARY_PATH
    export CPPFLAGS=-I$DIR/NETCDF/include 
    export LDFLAGS=-L$DIR/NETCDF/lib
    ./configure --prefix=$DIR/NETCDF --disable-shared
    make 
    make install
    make check

And now I am executing the install commands for nceplibs:

cd $HOME/WRF/Downloads
git clone https://github.com/NOAA-EMC/NCEPLIBS
cd NCEPLIBS
mkdir -p build && cd build
export CC=gcc
export FC=gfortran
export CXX=g++
export FFLGAS=-fallow-argument-mismatch
export FCFLAGS=-fallow-argument-mismatch

export JPEG_LIBRARY=/home/will/WRF/Libs/grib2/lib
export JPEG_INCLUDE_DIR=/home/will/WRF/Libs/grib2/include
export JASPER_LIBRARIES=/home/will/WRF/Libs/grib2/lib
export JASPER_INCLUDE_DIR=/home/will/WRF/Libs/grib2/include

export INSTALL_PREFIX=$HOME/WRF/Libs/nceplibs
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} ..
make
make install

However whenever I try to run the make command it comes up saying that the exports for JASPER & JPEG are not found. I believe it has to do with cmake but I am not 100% certain.

This is the error I see on my terminal.

[ 39%] Completed 'w3nco'
[ 40%] Built target w3nco
[ 41%] Performing update step for 'g2'
[ 42%] No patch step for 'g2'
[ 42%] Performing configure step for 'g2'
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR
  JPEG_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindJasper.cmake:62 (find_package_handle_standard_args)
  CMakeLists.txt:24 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/will/WRF/Downloads/NCEPLIBS/build/g2/src/g2-build/CMakeFiles/CMakeOutput.log".
make[2]: *** [CMakeFiles/g2.dir/build.make:92: g2/src/g2-stamp/g2-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:348: CMakeFiles/g2.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I am not sure if I have to put those values to the $PATH for them to be picked up by cmake or if there is a command I am missing.


Solution

 cmake -DCMAKE_PREFIX_PATH:PATH=$DIR/grib2 -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}  ..


Answered By - Will H
Answer Checked By - Mary Flores (WPSolving Volunteer)