check_install.sh

View page source

Example and Test Using the Installed Version of cppad_mixed

Syntax

bin/check_install.sh

build_type

Get the build_type used during the install:

cmd=`grep '^build_type=' bin/run_cmake.sh`
eval $cmd

Prefixes

Get the prefixes used during the install:

cmd=`grep '^cmake_install_prefix=' bin/run_cmake.sh`
eval $cmd
ipopt_prefix="$cmake_install_prefix"

cmake_libdir

Get the cmake_libdir used during the install:

cmd=`grep '^cmake_libdir=' bin/run_cmake.sh`
eval $cmd

example_file

This is the user example that we will compile using the installed version of cppad_mixed :

example_file='example/user/no_random.cpp'

PKG_CONFIG_PATH

Set the path used by $code pkg-config$$:

if [ "$PKG_CONFIG_PATH" == '' ]
then
export PKG_CONFIG_PATH="$ipopt_prefix/$cmake_libdir/pkgconfig"
else
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$ipopt_prefix/$cmake_libdir/pkgconfig"
fi

LD_LIBRARY_PATH

This setting is no longer required so test with it empty:

export LD_LIBRARY_PATH=''

Create Temporary

The following commands create a temporary directory, copy the example file into it, and make it the working directory:

mkdir -p build/tmp
cp $example_file build/tmp/example.cpp
cd build/tmp

example_name

The following command gets the example name, which is the example file with the .cpp at the end replaced by _xam :

example_name=`echo $example_file | sed -e 's|.*/||' -e 's|\.cpp|_xam|'`

main

The following command creates a main program (in the example.cpp file) that runs the example and reports the result of its return bool value:

cat << EOF >> example.cpp
int main(void)
{  if( ! $example_name() )
    {  std::cout << "$example_name: Error" << std::endl;
        std::exit(1);
    }
    std::cout << "$example_name: OK" << std::endl;
    exit(0);
}
EOF

eigen_cflags

The following command determines the flags necessary to compile with eigen on this system:

eigen_cflags=$(pkg-config --cflags eigen3 | sed -e 's|-I */|-isystem /|' )
# Changing -I to -isystem suppresses warnings in the eigen source code.

CHOLMOD_cflags

The following command determines the flags necessary to compile with eigen on this system:

CHOLMOD_cflags=$(pkg-config --cflags CHOLMOD)

gsl_libs

The following command determines the library link flags necessary to link ipopt on this system:

gsl_libs=`pkg-config --libs gsl`

ipopt_libs

The following command determines the library link flags necessary to link ipopt on this system:

ipopt_libs=`pkg-config --libs ipopt`

CHOLMOD_libs

The following command sets the library link flags necessary to link cholmod on this system:

CHOLMOD_libs=`pkg-config --libs CHOLMOD`

Run Example

The following commands run the example:

if ! ./example
then
    echo 'check_install.sh: Error'
    exit 1
fi
echo 'check_install.sh: OK'
exit 0