Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section will discuss the setup needed by users to use the installed Magics library and its applications.

Magics

...

environment variables

The variable $MAGPLUS_HOME is the path where Magics will find all auxiliary data at run-time. If Magics is installed where the configure prefix option was set to, this variable does NOT need to be set. Otherwise the variable needs to be set for all users of Magics programs. If Magics reports problems at run-time about missing coastlines or fonts this variable might not be set correctly.

Magics ++ provides feedback on the console. You can control the amount of messages plotted by setting any of the following environment variables:

$MAGPLUS_INFO - Information and hints to what Magics ++ is doing

$MAGPLUS_QUIET - suppresses the Magics ++ header, footer and info output – only errors and warnings will cause output

...

Info
Hint: If you choose a standard system folder, such as /usr or /usr/local/, for your installation you might not have to change any system environment variables.

$LD_LIBRARY_PATH - To work with shared libraries the locations of these libraries need to be known at run-time. This environment variable contains a list of paths where at run-time the system loader will look for libraries. To use the shared library version of Magics ++ the location of the library needs to be set in $LD_LIBRARY_PATH. If the variable is not set correctly the loader might pick up a version of Magics ++ which was not intended.

If EmosLib is compiled with Pgf90, it binds in libpgc.so dynamically at run-time and so the path to this library needs to be in $LD_LIBRARY_PATH.

$PATH - Magics ++ provides not only libraries, but also some executables. To use these, the $PATH needs to include the location of these programs. Usually this will be $MAGPLUS_HOME/bin.

magics-config

To simplify the user setup Magics++ installs a script called magics-config, which prints out the options to compile Magics++ programs. The options are based on the options used to compile Magics++. The program outputs the compilation and linkage options which can be used directly in the compilation instruction, as shown below.

To compile a C program and link it to Magics++ you only need to type

          gcc  shade.c  -o  shade  `magics-config  --clibs  --cxxflags`

To compile simple Magics Fortran programs you can use magics-config by typing In case a different suffix is used for Fortran code the call can be extended to There is a similar shortcut for C code called --compileC=test.c.

To do so $MAGPLUS_HOME/bin needs to be added to the $PATH first or magics-config called with its full path. Please be aware that the option '--print-setup' will tell you which environment variables you need to set before you can compile and run Magics++ programs. You might want to add this setup in your shell or start-up scripts. Below you find the usage help for magics-config.

 

Code Block
languagebash
titlemagics-config help text
Usage:  magics-config  [OPTION]  ...

Uses  by  default  version  2.12.5  of  Magics++.

Generic  options

    --version          output  Magics++  version  information.

    --help                display  this  help  and  exit.

    --print-setup  print  how  the  environment  can  be  set  up

Compilation  support  options

    --cxxflags        print  pre-processor  and  compiler  flags  for  C/C++

    --libs                print  linking  flags  for  C++

    --clibs              print  linking  flags  for  C

    --f90static      print  library  linking  information  (static)

    --f90shared      print  library  linking  information  (shared)

 

    --compile          compile  simple  Magics++  Fortran  programs  (default  single  precision!)   

                                    Example:  magics-config  --compile=wind.f

    --compileC        compile  simple  Magics++  C  programs   

                                    Example:  magics-config  --compileC=wind.c

    --suffix            set  suffix  of  Fortran  or  C  code  files

 

    --double            include  compiler  option  for  fortran  double  precision 

                                    (default  single  -  only  for  interface  -  internally  only  double  is  used)

    --64bit              include  fortran  option  for  64  bit

 

C/C++  flags  use  shared  libraries  if  possible,  otherwise  static  libraries  are  used.  '--double'  has  

NO  effect  on  C/C++  programs.

 

Install  directories  Magics++  was  configured  to

    --prefix[=DIR]

 

Compiling with pkg-config

pkg-config is a script that provides a unified interface for querying installed libraries for the purpose of compiling software from its source code. pkg-config was originally designed for Linux but is now also available for the various BSDs, Microsoft Windows, Mac OS X, and Solaris. It outputs various information about installed libraries. This information may include parameters for C or C++ compiler and parameters for linker.

This script is very similar to what magics-config offers, but pkg-config is more general while magics-config has very Magics specific options.

gcc  -o  test  test.c  $(pkg-config  --libs  --cflags  magics)

To find the information about Magics compilation the environment variable PKG_CONFIG_PATH needs to contain the directory $MAGPLUS_HOME/lib/pkgconfig. For more information visit pkg-config on Wikipedia.

Using Magics++ in your own configure scripts [advanced]

To simplify the use of the Magics library in software also using the autotools package, a script called magics.m4 is provided. The file can be found in the Magics++ install directory under share/aclocal/. It is recommended to copy the file into the own project and include it in the configure.ac file by typing

m4_include(m4/magics.m4)

...

.