You are here

Revision of HOWTO build OpenMx from the source repository from Tue, 09/24/2019 - 12:49

Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.

Contents

General Requirements for compiling OpenMx

note: The source code for OpenMx is on github as https://github.com/OpenMx/OpenMx

Compiling OpenMx requires that you have installed in R the other packages to which we link, or depend. It will be useful to also install suggested packages. As of May 2019, these were:

It pays to update these prior to building OpenMx to ensure you have the latest versions...

Also, note that if you need Rmpi on MacOS, you would need to install Open MPI so that the R package Rmpi can be built. You can get openmpi from https://www.open-mpi.org - root permission will be needed for the installation but it should go smoothly.

You can install all the packages used by OpenMx with the following code:

pkglist = c("Rcpp", "RcppEigen", "StanHeaders", "BH","rpf",
    "digest", "MASS" , "Matrix", 
    "mvtnorm", "numDeriv", "roxygen2", "lme4", "devtools")
 
install.packages(pkglist = pkglist)

See OS X build notes below if the R package RMPI mac install fails with mpi.h not found error.

Depends

    install.packages("R")

Linking to

    install.packages("Rcpp")
    install.packages("RcppEigen")
    install.packages("StanHeaders")
    install.packages("BH")
    install.packages("rpf")

Imports

    install.packages("digest") 
    install.packages("MASS") 
    install.packages("methods") 
    install.packages("Matrix") 
    install.packages("Rcpp") 
    install.packages("parallel") 

Suggests:

    install.packages("mvtnorm")  # for tests
    install.packages("numDeriv")  # for tests
    install.packages("lme4")  # for tests
    install.packages("roxygen2")  # for documentation
    install.packages("Rmpi")  # for HPC, can skip
    install.packages("snowfall")  # for HPC, can skip

Unix installation

OpenMx should compile under any Unix with the GNU compiler (See above for instructions on installing this if necessary). First you need to get the source.

GIT Source Archive

OpenMx source code is available on github. Development takes place on the 'master' branch. Once change sets on the master branch are 100% passing on our nightly test suite, changes are merged to the 'stable' branch. Any other branches are for work-in-progress and we can offer no stability guarantees.

Building and Installing OpenMx from the downloaded source

cd (change directory) to the top directory, and make install

git clone https://github.com/OpenMx/OpenMx.git
cd OpenMx/
make install

Options for the make process are as follows:

make build # build a binary release of the OpenMx library for export.
make install # create the OpenMx library and tries to install it as an R library.
make check # create the OpenMx library and runs the R library checker.
make html # create the Sphinx documentation in the docs/build/html directory.  You will need to have the Sphinx package installed.
make pdf # create a pdf file in the build directory of the OpenMx documentation.
make clean # clean out the build subdirectory.  Sometimes you may need to run "make clean" if you get error messages with the other make build.
make test # run all the models in the demo and models/passing subdirectories.  The number of errors found will be reported (should be 0).

Problems With make

  1. Try make clean
  2. Ensure your copy of the source is up-to-date (navigate to the trunk directory of your local copy and git update):
    cd ~/OpenMx/
    git fetch origin
    git reset --hard origin/master   # or origin/stable
    
  3. Checkout the repository again.
  4. Make sure you have all the R dependencies installed.
  5. Last but not least, make sure that if you are building for multicore, the command R points to R64, not to plain 32-bit R. For example, if the command
    which R

    returns /usr/bin/R, and

    ls -l /usr/bin/R

    returns /usr/bin/R@ -> /Library/Frameworks/R.framework/Resources/bin/R it would be necessary to fix this with

    sudo unlink /usr/bin/R
    sudo ln -s /Library/Frameworks/R.framework/Resources/bin/R64 /usr/bin/R
    

    Otherwise, you may encounter cryptic messages such as

    Error in dyn.load(file, DLLpath = DLLpath, ...) : 
      unable to load shared object '/Library/Frameworks/R.framework/Versions/2.14/Resources/library/OpenMx/libs/i386/OpenMx.so':
      dlopen(/Library/Frameworks/R.framework/Versions/2.14/Resources/library/OpenMx/libs/i386/OpenMx.so, 6): Symbol not found: _GOMP_parallel_end
      Referenced from: /Library/Frameworks/R.framework/Versions/2.14/Resources/library/OpenMx/libs/i386/OpenMx.so
      Expected in: dynamic lookup
    

OS X installation

    Installing OpenMx from Source on OS X 10.9.2 and higher

  1. Install Xcode from the App Store
  2. Run this command in a terminal window to get standard C libraries etc:
    xcode-select --install

    The command line is used just this first time: The app store will update it thereafter.

  3. If the RMPI package fails to build with configure: error: "Cannot find mpi.h header file", then

    brew install mpi

    should get you on the path to have rmpi working.

  4. Download OpenMx into a directory with the name OpenMx (or whatever you prefer, but this is standard)
    git clone git://github.com/OpenMx/OpenMx.git
    cd OpenMx
  5. Download and Install latest R (as old as 3.0.x should still work)
  6. In R, if necessary, install required packages (see dependencies above )
  7. Download HPC g++ gcc * gfortran 4.9 (at least some later versions also work) from hpc.sourceforge.net, change directory to wherever it downloaded, and install it in
    /usr/local/bin

    with

    sudo tar -xvf gcc-4.9-bin.tar -C /
  8. Change to the top directory of OpenMx repository (or whichever source you want, e.g., in tags)
    git fetch origin
    git reset --hard origin/master
  9. Create or edit the file `~/.R/Makevars` so that it contains the following lines. If there's other stuff in the file, put these lines at the end of it.

    CC = /usr/local/bin/gcc
    CXX = /usr/local/bin/g++
    CXX1X = /usr/local/bin/g++
    FC = /usr/local/bin/gfortran
    F77 = /usr/local/bin/gfortran

    Alternatively run make install, which will likely fail, but look for the line that says something like "Change default C/C++ compiler and default compile flags by editing /SomeLongPathToADirectory/Makeconf", and add the above lines to that file.

  10. Edit the file identified in the previous step (in my case it is /Library/Frameworks/R.framework/Resources/etc/Makeconf ) and replace the CLANG compilers with g++ gcc & gfortran, by changing the 4 lines beginning CC, CXX, FC and F77 to read:
  11. Important get the correct version of NPSOL for your build.
    You will need to find the right right version of libnpsol.a (one copy is appended at the bottom of this wiki page).

    This must be moved to the correct location for the compiler to find it. By default this will be trunk/inst/npsol/osx/

  12. make install
    Now you can make (compile) and install (move the package in R's library folder) OpenMx.

    Again, from the top directory, simply run make install Other options for building (like check) are described in full in the unix section above and work for Mac too.

Validate the installation by running make test - it takes some time to complete.

The above steps have been tested on a newly (Aug 5 2014) purchased OS X 10.9.2 system. For subsequent rebuilds from source the procedure is much easier:

cd OpenMx
git fetch origin
git reset --hard origin/master
make install

Windows installation

First install R and the packages that OpenMx "depends", "suggests", and "links to" as recommended above. You will then have to install Rtools. We recommend that you also install cygwin, but it might not be technically required. Rtools is a set of compilers and command line tools that R distributes for use with package development in Windows environments. Download the latest version of Rtools from their website and run the installer. It is currently hosted on the CRAN website, under "Download R for Windows" and then "Rtools".

Before installing Rtools, decide if you want to install cygwin. We recommend installing cygwin for developers because cygwin is a Unix emulator that comes in handy for many tasks. In particular, developers must have some way of managing the Git version control system that OpenMx uses and is hosted on GitHub. Cygwin is an excellent way to to manage Git, but many graphical user interfaces for Git on Windows also exist. If you decide to use cygwin, then install the 32-bit version (yes, even if you're on a 64-bit machine). Be sure to search through and add "git" to the installation when asked what packages to install. Cygwin generally take a while to install. Once installed add cygwin to your PATH variable. See here for help on setting the path in Windows 2000/XP/Vista/8/10. Cygwin is usually something like "C:\cygwin\bin".

Once you have installed (or decided against installing) cygwin, download the latest version of Rtools from their website and run the installer. It is currently hosted on the CRAN website, under "Download R for Windows" and the "Rtools". During the installation, you will be asked if you want to install Cygwin DLLs. If you have installed cygwin separately, then do not install the Cygwin DLLs. However, if you have not installed Cygwin separately, then check the box to install the Cygwin DLLs. You will also be given the opportunity to edit the PATH variable in the Rtools installation. You can edit during installation or after; it is up to you. See here for help on setting the path in Windows 2000/XP/Vista/8/10. The default R directory is placed in C:\Program Files\R\R-3.X.X\bin. The default Rtools directory is C:\Rtools.

When you examine your PATH variable on a 64-bit Windows system, it should have something like this in it: "C:\Program Files\R\R-3.4.4\bin\x64;C:\Rtools\bin;C:\Rtools\mingw_64\bin;C:\cygwin\bin". If you're on a 32-bit system, it should be the following instead: "C:\Program Files\R\R-3.4.4\bin\i386;C:\Rtools\bin;C:\Rtools\mingw_32\bin;C:\cygwin\bin".

Once the above are installed, you should be ready to do development work and build your own version of OpenMx. If you have Cygwin, then you can clone the git repository at instructed under the Unix section. If you have some other Git interface, use that. We recommend cloning the OpenMx repository into a folder that does not contain any spaces in its absolute path. When running "make install" use the Windows cmd promptand run it as Administrator if you want to install OpenMx to the R system package directory. If you receive a permission denied error when running "make install", follow the instructions on the "I don't have permission" item of the R FAQ.

Then follow the instructions for the Unix installation.

Buildbot

Commits to the source repository are automatically tested by our Travis CI.

AttachmentSize
Plain text icon libnpsol.a.txt439.77 KB

Comments

You can also check the status of your working copy

The build instructions for Windows are extremely out-of-date...