Skip to content

ld error on macOS #99

@dmeoli

Description

@dmeoli

hello,

I wrote this bash script to install coin on Linux os:

  // Install COIN-OR CoinUtils and Osi/Clp
  echo "Installing COIN-OR CoinUtils and Osi/Clp..."
  if [ "$HAS_SUDO" -eq 1 ]; then
    apt-get install -y -q coinor-libcoinutils-dev libbz2-dev liblapack-dev libopenblas-dev
  fi
  CoinOr_ROOT="${INSTALL_ROOT}/coin-or"
  if [ ! -d "$CoinOr_ROOT" ]; then
    cd "$INSTALL_ROOT"
    curl -O https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
    chmod u+x coinbrew
    # Build CoinUtils
    ./coinbrew build CoinUtils --latest-release --skip-dependencies --prefix="$CoinOr_ROOT" --tests=none
    # Build Osi with or without CPLEX
    osi_build_flags=(
      "--latest-release"
      "--skip-dependencies"
      "--prefix=$CoinOr_ROOT"
      "--tests=none"
    )
    if [ "$install_cplex" -eq 0 ]; then
      osi_build_flags+=("--without-cplex")
    else
      osi_build_flags+=(
        "--with-cplex"
        "--with-cplex-lib=-L${CPLEX_ROOT}/cplex/lib/x86-64_linux/static_pic -lcplex -lpthread -lm"
        "--with-cplex-incdir=${CPLEX_ROOT}/cplex/include/ilcplex"
      )
    fi
    # Build Osi with or without Gurobi
    if [ "$install_gurobi" -eq 0 ]; then
      osi_build_flags+=("--without-gurobi")
    else
      osi_build_flags+=(
        "--with-gurobi"
        "--with-gurobi-lib=-L${GUROBI_ROOT}/linux64/lib -lgurobi100"
        "--with-gurobi-incdir=${GUROBI_ROOT}/linux64/include"
      )
    fi
    ./coinbrew build Osi "${osi_build_flags[@]}"
    # Build Clp
    ./coinbrew build Clp --latest-release --skip-dependencies --prefix="$CoinOr_ROOT" --tests=none
    rm -Rf coinbrew build CoinUtils Osi Clp
    export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${CoinOr_ROOT}/lib"
    if [ "$HAS_SUDO" -eq 1 ]; then
      sh -c "echo '${CoinOr_ROOT}/lib' > /etc/ld.so.conf.d/coin-or.conf"
      ldconfig
    fi
  else
    echo "COIN-OR already installed."
  fi

and this perfectly works, then I tried to adapt this one for macOS:

  // Install COIN-OR CoinUtils and Osi/Clp
  echo "Installing COIN-OR CoinUtils and Osi/Clp..."
  CoinOr_ROOT="${INSTALL_ROOT}/coin-or"
  if [ ! -d "$CoinOr_ROOT" ]; then
    brew install coinutils lapack openblas
    cd "$INSTALL_ROOT"
    curl -O https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
    chmod u+x coinbrew
    # Build CoinUtils
    ./coinbrew fetch CoinUtils --no-prompt
    # Build Osi with or without CPLEX
    osi_build_flags=(
      "--prefix=$CoinOr_ROOT"
      "--no-prompt"
      "--tests=none"
    )
    if [ "$install_cplex" -eq 0 ]; then
      osi_build_flags+=("--without-cplex")
    else
      osi_build_flags+=(
        "--with-cplex"
        "--with-cplex-lib=-L${CPLEX_ROOT}/cplex/lib/x86-64_osx/static_pic -lcplex -lm"
        "--disable-cplex-libcheck"
        "--with-cplex-incdir=${CPLEX_ROOT}/cplex/include/ilcplex"
      )
    fi
    # Build Osi with or without Gurobi
    if [ "$install_gurobi" -eq 0 ]; then
      osi_build_flags+=("--without-gurobi")
    else
      osi_build_flags+=(
        "--with-gurobi"
        "--with-gurobi-lib=-L${GUROBI_ROOT}/macos_universal2/lib -lgurobi100"
        "--disable-gurobi-libcheck"
        "--with-gurobi-incdir=${GUROBI_ROOT}/macos_universal2/include"
      )
    fi
    ./coinbrew build Osi "${osi_build_flags[@]}"
    # Build Clp
    ./coinbrew build Clp --prefix="$CoinOr_ROOT" --tests=none
    rm -Rf coinbrew build CoinUtils Osi Clp
    export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${CoinOr_ROOT}/lib"
  else
    echo "COIN-OR already installed."
  fi

but I am obtaining this error:

. . .

OsiCpxSolverInterface::resolve() in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::resolve() in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::resolve() in libOsiCpx.1.13.11.dylib-master.o
...
"_CPXsolninfo", referenced from:
OsiCpxSolverInterface::getColSolution() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getColSolution() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getRowPrice() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getReducedCost() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getRowActivity() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getObjValue() const in libOsiCpx.1.13.11.dylib-master.o
OsiCpxSolverInterface::getIterationCount() const in libOsiCpx.1.13.11.dylib-master.o
...
"_CPXwriteprob", referenced from:
OsiCpxSolverInterface::writeMps(char const*, char const*, double) const in libOsiCpx.1.13.11.dylib-master.o
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libOsiCpx.la] Error 1
make: *** [all-recursive] Error 1

does anyone help me to understand what am I wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions