meco-group / fatrop

Fatrop is a nonlinear optimal control problem solver that aims to be fast, support a broad class of optimal control problems and achieve a high numerical robustness.
https://meco-group.github.io/fatrop/
GNU Lesser General Public License v3.0
146 stars 16 forks source link

FindCasadi.cmake error #3

Closed Nabil-Miri closed 10 months ago

Nabil-Miri commented 11 months ago

Hello,

I was trying to use spectool and I am getting an error with finding casadi when compiling the CMakeLists file.

The FindCasadi.cmake gives an error Could not find CasADi libs.

find_library(CASADI_LIBRARY
    NAMES casadi
    HINTS ${CASADI_INCLUDE_DIR}/../lib $ENV{CASADI_PREFIX}/lib)
if(CASADI_LIBRARY)
    set(CASADI_LIBRARIES ${CASADI_LIBRARIES} ${CASADI_LIBRARY})
endif()

if(CASADI_LIBRARIES)
  message(STATUS "Found CasADi libs: ${CASADI_LIBRARIES}")
else()
  message(STATUS "Could not find CasADi libs")
endif()

I have installed casadi using pip install casadi and in the download files I cant find an lib fill inside the casadi folder. I can only find a fill called lib64 and using it didn't work.

(base) nabil@ubuntu:~/miniconda3/lib/python3.11/site-packages/casadi$ find . -type d -name "lib*" ./lib64

Could you please guide me into what could be missing in my case?

Nabil-Miri commented 11 months ago

Content of the casadi folder:

(base) nabil@ubuntu:~/miniconda3/lib/python3.11/site-packages/casadi$ ls casadi-cli libcasadi_conic_qrqp.so libcasadi_nlpsol_alpaqa.so.3.7 libcasadi_xmlfile_tinyxml.so.3.7 libindirect.a casadi.py libcasadi_conic_qrqp.so.3.7 libcasadi_nlpsol_ampl.so libCbc.la libipopt.la _casadi.so libcasadi_conic_superscs.so libcasadi_nlpsol_ampl.so.3.7 libCbc.so libipopt.so cbc libcasadi_conic_superscs.so.3.7 libcasadi_nlpsol_blocksqp.so libCbc.so.3 libipopt.so.3 clp libcasadi_importer_shell.so libcasadi_nlpsol_blocksqp.so.3.7 libCbc.so.3.10.11 libipopt.so.3.14.11 cmake libcasadi_importer_shell.so.3.7 libcasadi_nlpsol_bonmin.so libCbcSolver.la liblinsys.a highs libcasadi_integrator_collocation.so libcasadi_nlpsol_bonmin.so.3.7 libCbcSolver.so libOsiCbc.la include libcasadi_integrator_collocation.so.3.7 libcasadi_nlpsol_feasiblesqpmethod.so libCbcSolver.so.3 libOsiCbc.so init.py libcasadi_integrator_cvodes.so libcasadi_nlpsol_feasiblesqpmethod.so.3.7 libCbcSolver.so.3.10.11 libOsiCbc.so.3 lib64 libcasadi_integrator_cvodes.so.3.7 libcasadi_nlpsol_ipopt.so libCgl.la libOsiCbc.so.3.10.11 libalpaqa-dl-loader.so libcasadi_integrator_idas.so libcasadi_nlpsol_ipopt.so.3.7 libCgl.so libOsiClp.la libalpaqa-dl-loader.so.1.0.0 libcasadi_integrator_idas.so.3.7 libcasadi_nlpsol_knitro.so libCgl.so.1 libOsiClp.so libalpaqa.so libcasadi_integrator_rk.so libcasadi_nlpsol_knitro.so.3.7 libCgl.so.1.10.8 libOsiClp.so.1 libalpaqa.so.1.0.0 libcasadi_integrator_rk.so.3.7 libcasadi_nlpsol_qrsqp.so libClp.la libOsiClp.so.1.14.9 libblasfeo.so libcasadi_interpolant_bspline.so libcasadi_nlpsol_qrsqp.so.3.7 libClp.so libOsiCommonTests.la libbonmin.la libcasadi_interpolant_bspline.so.3.7 libcasadi_nlpsol_scpgen.so libClp.so.1 libOsiCommonTests.so libbonmin.so libcasadi_interpolant_linear.so libcasadi_nlpsol_scpgen.so.3.7 libClp.so.1.14.9 libOsiCommonTests.so.1 libbonmin.so.4 libcasadi_interpolant_linear.so.3.7 libcasadi_nlpsol_sleqp.so libClpSolver.la libOsiCommonTests.so.1.13.9 libbonmin.so.4.8.9 libcasadi_linsol_csparsecholesky.so libcasadi_nlpsol_sleqp.so.3.7 libClpSolver.so libOsi.la libcasadi_conic_cbc.so libcasadi_linsol_csparsecholesky.so.3.7 libcasadi_nlpsol_snopt.so libClpSolver.so.1 libOsi.so libcasadi_conic_cbc.so.3.7 libcasadi_linsol_csparse.so libcasadi_nlpsol_snopt.so.3.7 libClpSolver.so.1.14.9 libOsi.so.1 libcasadi_conic_clp.so libcasadi_linsol_csparse.so.3.7 libcasadi_nlpsol_sqpmethod.so libcoinmetis.la libOsi.so.1.13.9 libcasadi_conic_clp.so.3.7 libcasadi_linsol_lapacklu.so libcasadi_nlpsol_sqpmethod.so.3.7 libcoinmetis.so libosqp.a libcasadi_conic_cplex.so libcasadi_linsol_lapacklu.so.3.7 libcasadi_nlpsol_worhp.so libcoinmetis.so.2 libosqp.so libcasadi_conic_cplex.so.3.7 libcasadi_linsol_lapackqr.so libcasadi_nlpsol_worhp.so.3.7 libcoinmetis.so.2.0.0 libqdldl.a libcasadi_conic_gurobi.so libcasadi_linsol_lapackqr.so.3.7 libcasadi_rootfinder_fast_newton.so libcoinmumps.la libqdldl.so libcasadi_conic_gurobi.so.3.7 libcasadi_linsol_ldl.so libcasadi_rootfinder_fast_newton.so.3.7 libcoinmumps.so libquadmath-96973f99.so.0.0.0 libcasadi_conic_highs.so libcasadi_linsol_ldl.so.3.7 libcasadi_rootfinder_kinsol.so libcoinmumps.so.3 libsipopt.la libcasadi_conic_highs.so.3.7 libcasadi_linsol_lsqr.so libcasadi_rootfinder_kinsol.so.3.7 libcoinmumps.so.3.0.1 libsipopt.so libcasadi_conic_hpipm.so libcasadi_linsol_lsqr.so.3.7 libcasadi_rootfinder_newton.so libCoinUtils.la libsipopt.so.3 libcasadi_conic_hpipm.so.3.7 libcasadi_linsol_ma27.so libcasadi_rootfinder_newton.so.3.7 libCoinUtils.so libsipopt.so.3.14.11 libcasadi_conic_ipqp.so libcasadi_linsol_ma27.so.3.7 libcasadi_rootfinder_nlpsol.so libCoinUtils.so.3 libsleqp.so libcasadi_conic_ipqp.so.3.7 libcasadi_linsol_mumps.so libcasadi_rootfinder_nlpsol.so.3.7 libCoinUtils.so.3.11.10 libsleqp.so.1.0.1 libcasadi_conic_nlpsol.so libcasadi_linsol_mumps.so.3.7 libcasadi.so libcplex_adaptor.so libspral.a libcasadi_conic_nlpsol.so.3.7 libcasadi_linsol_qr.so libcasadi.so.3.7 libFortranHighs.so libsuperscs.a libcasadi_conic_osqp.so libcasadi_linsol_qr.so.3.7 libcasadi_sundials_common.so libgfortran-040039e1.so.5.0.0 libtrlib.so libcasadi_conic_osqp.so.3.7 libcasadi_linsol_symbolicqr.so libcasadi_sundials_common.so.3.7 libgurobi_adaptor.so libtrlib.so.0.4 libcasadi_conic_proxqp.so libcasadi_linsol_symbolicqr.so.3.7 libcasadi-tp-openblas.so libhighs.so pkgconfig libcasadi_conic_proxqp.so.3.7 libcasadi_linsol_tridiag.so libcasadi-tp-openblas.so.0 libhighs.so.1.6 pycache libcasadi_conic_qpoases.so libcasadi_linsol_tridiag.so.3.7 libcasadi-tp-openblas.so.0.3 libhighs.so.1.6.0 tools libcasadi_conic_qpoases.so.3.7 libcasadi_nlpsol_alpaqa.so libcasadi_xmlfile_tinyxml.so libhpipm.so

(base) nabil@ubuntu:~/miniconda3/lib/python3.11/site-packages/casadi$ ls lib64 cmake libtinyxml2.a pkgconfig

lvanroye commented 11 months ago

Hi Nabil,

Are you sure you pulled the latest version of the main branch? I think it should not use the findCasadi.cmake, unless something is wrong.

Best, Lander

Nabil-Miri commented 11 months ago

Hello Lander,

I uncommented it because when spectool is CMakeLists.txt is build, I get this error

[cmake] CMake Error at fatrop/spectool/CMakeLists.txt:17 (message):
[cmake]   Please specify the path to casadi headers

Should I fill the string of these variables or should it be done automatically when installing casadi?

# add option for specifying casadi headers location
set(CASADI_SOURCE "" CACHE STRING "Path to casadi headers")
# add option for specifying casadi library location
set(CASADI_LIB "" CACHE STRING "Path to casadi library")
if(NOT CASADI_SOURCE)
    message(FATAL_ERROR "Please specify the path to casadi headers")
endif()
if(NOT CASADI_LIB)
    message(FATAL_ERROR "Please specify the path to casadi library")
endif()

Best, Nabil

lvanroye commented 11 months ago

Hi Nabil,

The installation process of fatrop::spectool is not very easy at this point. Improving this is a current work of progress.

At this point you will have to compile casadi from source, instead of using pip (make sure to replace {python packages path}, usually a directory called site-packages or dist-packages in your virtual environment directory):

git clone https://github.com/casadi/casadi.git && cd casadi && mkdir build cd casadi/build && cmake -DWITH_IPOPT=OFF -DWITH_BUILD_IPOPT=OFF -DWITH_BUILD_MUMPS=OFF -DWITH_BUILD_METIS=OFF -DWITH_OPENMP=OFF -DWITH_THREAD=OFF -DWITH_PYTHON=ON -DWITH_PYTHON3=ON -DPYTHON_PREFIX={python packages path}

Next use the following cmake options for fatrop again replace what's between brackets {}:

cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DENABLE_MULTITHREADING=OFF -DCASADI_SOURCE={directory where casadi was cloned} -DCASADI_LIB={casadi_lib}/libcasadi.so -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON

Feel free to reach out if you run into trouble!

Nabil-Miri commented 11 months ago

Hello Lander,

Thanks for the continuous support. I used these commands and got the respective outputs.

nabil@ubuntu:~$ git clone https://github.com/casadi/casadi.git && cd casadi && mkdir build && cd build && cmake -DWITH_IPOPT=OFF -DWITH_BUILD_IPOPT=OFF -DWITH_BUILD_MUMPS=OFF -DWITH_BUILD_METIS=OFF -DWITH_OPENMP=OFF -DWITH_THREAD=OFF -DWITH_PYTHON=ON -DWITH_PYTHON3=ON -DPYTHON_PREFIX=/usr/lib/python3/dist-packages ..
Cloning into 'casadi'...
remote: Enumerating objects: 180310, done.
remote: Counting objects: 100% (27754/27754), done.
remote: Compressing objects: 100% (10848/10848), done.
remote: Total 180310 (delta 15634), reused 27557 (delta 15531), pack-reused 152556
Receiving objects: 100% (180310/180310), 139.19 MiB | 7.80 MiB/s, done.
Resolving deltas: 100% (133888/133888), done.
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 9.4.0
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- No flag needed for enabling C++11 features.
EXTERNAL_CMAKE_COMMAND: /usr/bin/cmake
CXX /usr/bin/c++
FC /usr/bin/gfortran
CC /usr/bin/cc
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- x86_64 architecture detected - setting flag -fPIC
CMAKE_C_COMPILER_ID: GNU
-- CMAKE_SYSTEM_NAME: Linux 
WITH_SPRAL OFF WITH_BUILD_SPRAL OFF
-- Found SWIG: /usr/bin/swig4.0 (found version "4.0.1") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so (found suitable version "3.8.10", minimum required is "3") 
PYTHONFLAGS: -DSWIG_TYPE_TABLE=casadi;-fvirtual;-DWITH_DEPRECATED_FEATURES;-DPy_USING_UNICODE;-noproxydel;-fastunpack;-modernargs;-py3;-DWITH_PYTHON3 3
COMPILE_FLAGS: -Wno-dynamic-class-memaccess -Wno-self-assign  -Wno-maybe-uninitialized
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- The following features have been enabled:

 * dynamic-loading, Support for import of FMI 2.0 binaries
 * sundials-interface, Interface to the ODE/DAE integrator suite SUNDIALS.
 * csparse-interface, Interface to the sparse direct linear solver CSparse.
 * tinyxml-interface, Interface to the XML parser TinyXML.

-- The following OPTIONAL packages have been found:

 * PythonLibs (required version >= 3)

-- The following REQUIRED packages have been found:

 * SWIG
 * PythonInterp (required version >= 3)

-- The following features have been disabled:

 * opencl-support, Enable just-in-time compiliation to CPUs and GPUs with OpenCL.
 * superscs-interface, Interface to QP solver SUPERSCS.
 * osqp-interface, Interface to QP solver OSQP.
 * dsdp-interface, Interface to the interior point SDP solver DSDP.
 * clang-interface, Interface to the Clang JIT compiler.
 * qpoases-interface, Interface to the active-set QP solver qpOASES.
 * blocksqp-interface, Interface to the NLP solver blockSQP.
 * cplex-interface, Interface to the QP solver CPLEX.
 * gurobi-interface, Interface to the (mixed-integer) QP solver GUROBI
 * knitro-interface, Interface to the NLP solver KNITRO.
 * snopt-interface, Interface to the NLP solver KNITRO.
 * worhp-interface, Interface to the NLP solver Worhp (requires gfortran, gomp).
 * lapack-interface, Interface to LAPACK.
 * mumps-interface, Interface to MUMPS.
 * spral-interface, Interface to SPRAL.
 * clp-interface, Interface to the LP solver CLP.
 * cbc-interface, Interface to the LP solver CBC.
 * ipopt-interface, Interface to the NLP solver Ipopt.
 * bonmin-interface, Interface to the MINLP framework Bonmin.
 * highs-interface, Interface to the MILP / QP solver HiGHS.
 * sleqp-interface, Interface to the NLP solver SLEQP.
 * alpaqa-interface, Interface to the NLP solver Alpaqa.
 * proxqp-interface, Interface to QP solver PROXQP.
 * ooqp-interface, Interface to the QP solver OOQP (requires BLAS and HSL libraries).
 * sqic-interface, Interface to the QP solver SQIC.
 * ampl-interface, Interface to the AMPL solver library.
 * slicot-interface, Interface to the controls library SLICOT.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/nabil/casadi/build

and

nabil@ubuntu:~/casadi/build$ cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DENABLE_MULTITHREADING=OFF -DCASADI_SOURCE=/home/nabil/casadi -DCASADI_LIB={casadi_lib}/libcasadi.so -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON
-- No flag needed for enabling C++11 features.
EXTERNAL_CMAKE_COMMAND: /usr/bin/cmake
CXX 
FC 
CC 
-- x86_64 architecture detected - setting flag -fPIC
CMAKE_C_COMPILER_ID: GNU
-- CMAKE_SYSTEM_NAME: Linux 
WITH_SPRAL OFF WITH_BUILD_SPRAL OFF
PYTHONFLAGS: -DSWIG_TYPE_TABLE=casadi;-fvirtual;-DWITH_DEPRECATED_FEATURES;-DPy_USING_UNICODE;-noproxydel;-fastunpack;-modernargs;-py3;-DWITH_PYTHON3 3
COMPILE_FLAGS: -Wno-dynamic-class-memaccess -Wno-self-assign  -Wno-maybe-uninitialized
-- The following features have been enabled:

 * dynamic-loading, Support for import of FMI 2.0 binaries
 * sundials-interface, Interface to the ODE/DAE integrator suite SUNDIALS.
 * csparse-interface, Interface to the sparse direct linear solver CSparse.
 * tinyxml-interface, Interface to the XML parser TinyXML.

-- The following REQUIRED packages have been found:

 * PythonInterp (required version >= 3)
 * SWIG

-- The following features have been disabled:

 * opencl-support, Enable just-in-time compiliation to CPUs and GPUs with OpenCL.
 * superscs-interface, Interface to QP solver SUPERSCS.
 * osqp-interface, Interface to QP solver OSQP.
 * dsdp-interface, Interface to the interior point SDP solver DSDP.
 * clang-interface, Interface to the Clang JIT compiler.
 * qpoases-interface, Interface to the active-set QP solver qpOASES.
 * blocksqp-interface, Interface to the NLP solver blockSQP.
 * cplex-interface, Interface to the QP solver CPLEX.
 * gurobi-interface, Interface to the (mixed-integer) QP solver GUROBI
 * knitro-interface, Interface to the NLP solver KNITRO.
 * snopt-interface, Interface to the NLP solver KNITRO.
 * worhp-interface, Interface to the NLP solver Worhp (requires gfortran, gomp).
 * lapack-interface, Interface to LAPACK.
 * mumps-interface, Interface to MUMPS.
 * spral-interface, Interface to SPRAL.
 * clp-interface, Interface to the LP solver CLP.
 * cbc-interface, Interface to the LP solver CBC.
 * ipopt-interface, Interface to the NLP solver Ipopt.
 * bonmin-interface, Interface to the MINLP framework Bonmin.
 * highs-interface, Interface to the MILP / QP solver HiGHS.
 * sleqp-interface, Interface to the NLP solver SLEQP.
 * alpaqa-interface, Interface to the NLP solver Alpaqa.
 * proxqp-interface, Interface to QP solver PROXQP.
 * ooqp-interface, Interface to the QP solver OOQP (requires BLAS and HSL libraries).
 * sqic-interface, Interface to the QP solver SQIC.
 * ampl-interface, Interface to the AMPL solver library.
 * slicot-interface, Interface to the controls library SLICOT.

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BLASFEO_TARGET
    CASADI_LIB
    CASADI_SOURCE
    ENABLE_MULTITHREADING
    WITH_SPECTOOL

-- Build files have been written to: /home/nabil/casadi/build

Should it work like this or should I also run sudo make install ?

BTW how to run the spectool examples? For now, I replaced the RunFatrop code with the code inside spectool/examples/example.cpp and built the CMakelists but it still didn't find casadi.

[build] /home/nabil/fatrop/fatrop/spectool/spec/ocp.hpp:2:10: fatal error: casadi/casadi.hpp: No such file or directory
[build]     2 | #include <casadi/casadi.hpp>
[build]       |          ^~~~~~~~~~~~~~~~~~~

Thanks, Nabil

lvanroye commented 11 months ago

Hi Nabil,

Sorry you should have -DCASADI_SOURCE={directory where casadi was cloned} instead of what i said previously (-DCASADI_SOURCE={directory where casadi was cloned}/casadi)

lvanroye commented 11 months ago

Oh and yes, you should run sudo make install for casadi as well to install the compiled casadi-python!

Nabil-Miri commented 11 months ago

Hi Nabil,

Sorry you should have -DCASADI_SOURCE={directory where casadi was cloned} instead of what i said previously (-DCASADI_SOURCE={directory where casadi was cloned}/casadi)

Hi Lander,

nabil@ubuntu:~/casadi/build$ cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DENABLE_MULTITHREADING=OFF -DCASADI_SOURCE=/home/nabil -DCASADI_LIB={casadi_lib}/libcasadi.so -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON
-- No flag needed for enabling C++11 features.
EXTERNAL_CMAKE_COMMAND: /usr/bin/cmake
CXX 
FC 
CC 
-- x86_64 architecture detected - setting flag -fPIC
CMAKE_C_COMPILER_ID: GNU
-- CMAKE_SYSTEM_NAME: Linux 
WITH_SPRAL OFF WITH_BUILD_SPRAL OFF
PYTHONFLAGS: -DSWIG_TYPE_TABLE=casadi;-fvirtual;-DWITH_DEPRECATED_FEATURES;-DPy_USING_UNICODE;-noproxydel;-fastunpack;-modernargs;-py3;-DWITH_PYTHON3 3
COMPILE_FLAGS: -Wno-dynamic-class-memaccess -Wno-self-assign  -Wno-maybe-uninitialized
-- The following features have been enabled:

 * dynamic-loading, Support for import of FMI 2.0 binaries
 * sundials-interface, Interface to the ODE/DAE integrator suite SUNDIALS.
 * csparse-interface, Interface to the sparse direct linear solver CSparse.
 * tinyxml-interface, Interface to the XML parser TinyXML.

-- The following REQUIRED packages have been found:

 * PythonInterp (required version >= 3)
 * SWIG

-- The following features have been disabled:

 * opencl-support, Enable just-in-time compiliation to CPUs and GPUs with OpenCL.
 * superscs-interface, Interface to QP solver SUPERSCS.
 * osqp-interface, Interface to QP solver OSQP.
 * dsdp-interface, Interface to the interior point SDP solver DSDP.
 * clang-interface, Interface to the Clang JIT compiler.
 * qpoases-interface, Interface to the active-set QP solver qpOASES.
 * blocksqp-interface, Interface to the NLP solver blockSQP.
 * cplex-interface, Interface to the QP solver CPLEX.
 * gurobi-interface, Interface to the (mixed-integer) QP solver GUROBI
 * knitro-interface, Interface to the NLP solver KNITRO.
 * snopt-interface, Interface to the NLP solver KNITRO.
 * worhp-interface, Interface to the NLP solver Worhp (requires gfortran, gomp).
 * lapack-interface, Interface to LAPACK.
 * mumps-interface, Interface to MUMPS.
 * spral-interface, Interface to SPRAL.
 * clp-interface, Interface to the LP solver CLP.
 * cbc-interface, Interface to the LP solver CBC.
 * ipopt-interface, Interface to the NLP solver Ipopt.
 * bonmin-interface, Interface to the MINLP framework Bonmin.
 * highs-interface, Interface to the MILP / QP solver HiGHS.
 * sleqp-interface, Interface to the NLP solver SLEQP.
 * alpaqa-interface, Interface to the NLP solver Alpaqa.
 * proxqp-interface, Interface to QP solver PROXQP.
 * ooqp-interface, Interface to the QP solver OOQP (requires BLAS and HSL libraries).
 * sqic-interface, Interface to the QP solver SQIC.
 * ampl-interface, Interface to the AMPL solver library.
 * slicot-interface, Interface to the controls library SLICOT.

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BLASFEO_TARGET
    CASADI_LIB
    CASADI_SOURCE
    ENABLE_MULTITHREADING
    WITH_SPECTOOL

-- Build files have been written to: /home/nabil/casadi/build

This is the new output. Is this right ?

Moreover, should I comment this part of the CMakeLists in the spectool or add the link?

# add option for specifying casadi headers location
set(CASADI_SOURCE "" CACHE STRING "Path to casadi headers")
# add option for specifying casadi library location
set(CASADI_LIB "" CACHE STRING "Path to casadi library")
if(NOT CASADI_SOURCE)
    message(FATAL_ERROR "Please specify the path to casadi headers")
endif()
if(NOT CASADI_LIB)
    message(FATAL_ERROR "Please specify the path to casadi library")
endif()
lvanroye commented 11 months ago

You should use cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DENABLE_MULTITHREADING=OFF -DCASADI_SOURCE=/home/nabil -DCASADI_LIB={casadi_lib}/libcasadi.so -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON

for compiling fatrop and not for compiling casadi. Also replace {casadi_lib}.

lvanroye commented 11 months ago

Is there a specific reason you'd like to use the spectool over rockit?

At this point the installation of rockit + fatrop is easier than fatrop with spectool and python bindings.

lvanroye commented 11 months ago

If you'd really want to continue with the (beta) spectool, you can also try it out in a docker container:

`FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y && apt-get upgrade -y

RUN apt install git wget -y RUN apt install gfortran liblapack-dev pkg-config cmake gcc --install-recommends -y RUN apt install swig -y RUN apt install g++ -y RUN apt install python3-pip -y RUN python3 -m pip install matplotlib RUN apt install pybind11-dev -y RUN git clone https://github.com/casadi/casadi.git && cd casadi && mkdir build RUN cd casadi/build && cmake \ -DWITH_IPOPT=OFF -DWITH_BUILD_IPOPT=OFF\ -DWITH_BUILD_MUMPS=OFF -DWITH_BUILD_METIS=OFF\ -DWITH_OPENMP=OFF -DWITH_THREAD=OFF -DWITH_PYTHON=ON -DWITH_PYTHON3=ON -DPYTHON_PREFIX=/usr/local/lib/python3.10/dist-packages .. RUN cd casadi/build && make -j && make install RUN ldconfig RUN git clone https://gitlab.kuleuven.be/robotgenskill/fatrop/fatrop.git --recursive WORKDIR fatrop RUN export CMAKE_ARGS="-DWITH_PYTHON=ON -DWITH_SPECTOOL=ON -DBLASFEO_TARGET=X64_AUTOMATIC -DENABLE_MULTITHREADING=OFF -DCASADI_SOURCE=/casadi/ -DCASADI_LIB=/casadi/build/lib/libcasadi.so" && cd fatropy && pip install .`

Nabil-Miri commented 10 months ago

Hello Lander, Thanks for your continuous support.

Noted. I will try to compile fatrop and will keep you updated.

Is there a specific reason you'd like to use the spectool over rockit?

At this point the installation of rockit + fatrop is easier than fatrop with spectool and python bindings.

My goal is to implement Fatrop instead of Ipopt in our own NMPC for trajectory planning. We decided to write a wrapper for OCP definitions used by Fatrop rather than Fatrop solver itself as it seems to be tedious. Moreover, our repo is in C++ and rockit uses only python. Thus, spectool seems to be more suitable to use.

Note: I am trying to using cmake for casadi in my VM but for some reason it get stuck and doesn't compile.

lvanroye commented 10 months ago

Hi Nabil,

I see, it is indeed not possible to use rockit from C++.

To address your comments, I have changed the installation procedure of spectool a bit. Now it does make use of the findcasadi.cmake, such that you don't have to set the -DCASADI_SOURCE and the -DCASADI_LIB variables manually.

There is one thing that you will have to do: you will have to install casadi with the -DINSTALL_INTERNAL_HEADERS=ON option. This is because (currently) the spectool library makes use of some internal casadi functions that are not available in the public casadi api. More specifically this is the casadi/core/function_internal.hpp.

So now,

1) pull the updated main branch from github

2) Install casadi with

cd {casadi build dir}
cmake .. {your casadi options} -DINSTALL_INTERNAL_HEADERS=ON
make -j 8
sudo make install

3) Build fatrop

cd {your fatrop build dir}
cmake .. -DWITH_SPECTOOL=ON
make -j 8

In the process make sure:

It's a bit annoying that for now you have to use the INSTALL_INTERNAL_HEADERS option in the casadi installation process. But this will be resolved in the near future, by making sure fatrop only uses headers that are available from the public casadi api.

Nabil-Miri commented 10 months ago

Hi Lander,

Thanks a lot for the detailed info and the changes to make installation easier.

I will try again the installation and return back to you. Hope all works fine.

Nabil-Miri commented 10 months ago

Hello Lander,

I am trying to cmake fatrop but I am getting an error. First, is there a min python version for it ?

nabilmiri@lsawyer:~/fatrop/build$ cmake -DBLASFEO_TARGET=X64_AUTOMATIC -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Target: BLASFEO is X64_AUTOMATIC
-- using BLASFEO with cmake from git submodule.
CMake Warning (dev) at external/blasfeo/CMakeLists.txt:41 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Using linear algebra: HIGH_PERFORMANCE
-- Using matrix format: PANELMAJ
-- Using external BLAS: 0
-- Testing target X64_INTEL_HASWELL: assembly compilation [success]
-- Testing target X64_INTEL_HASWELL: assembly run [success]
-- Testing target X64_INTEL_HASWELL: intrinsic compilation [success]
-- Testing target X64_INTEL_HASWELL: intrinsic run [success]
-- Detected target X64_INTEL_HASWELL
-- pybind11 v2.12.0 dev1
-- Found PythonInterp: /usr/bin/python3.6 (found suitable version "3.6.9", minimum required is "3.6") 
CMake Error at external/pybind11/tools/FindPythonLibsNew.cmake:147 (message):
  Python config failure:

  Traceback (most recent call last):

    File "<string>", line 6, in <module>

  ImportError: cannot import name 'sysconfig'

Call Stack (most recent call first):
  external/pybind11/tools/pybind11Tools.cmake:50 (find_package)
  external/pybind11/tools/pybind11Common.cmake:188 (include)
  external/pybind11/CMakeLists.txt:211 (include)

-- Configuring incomplete, errors occurred!
See also "/home/nabilmiri/fatrop/build/CMakeFiles/CMakeOutput.log".

I have tried also to use python 3.8:

nabilmiri@lsawyer:~/fatrop/build$ cmake -DBLASFEO_TARGET=X64_AUTOMATIC -DWITH_SPECTOOL=ON -DWITH_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/local/lib/python3.8/  ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Target: BLASFEO is X64_AUTOMATIC
-- using BLASFEO with cmake from git submodule.
CMake Warning (dev) at external/blasfeo/CMakeLists.txt:41 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Using linear algebra: HIGH_PERFORMANCE
-- Using matrix format: PANELMAJ
-- Using external BLAS: 0
-- Testing target X64_INTEL_HASWELL: assembly compilation [success]
-- Testing target X64_INTEL_HASWELL: assembly run [success]
-- Testing target X64_INTEL_HASWELL: intrinsic compilation [success]
-- Testing target X64_INTEL_HASWELL: intrinsic run [success]
-- Detected target X64_INTEL_HASWELL
-- pybind11 v2.12.0 dev1
-- Found PythonInterp: /usr/local/lib/python3.8 (Required is at least version "3.6") 
CMake Error at external/pybind11/tools/FindPythonLibsNew.cmake:147 (message):
  Python config failure:

Call Stack (most recent call first):
  external/pybind11/tools/pybind11Tools.cmake:50 (find_package)
  external/pybind11/tools/pybind11Common.cmake:188 (include)
  external/pybind11/CMakeLists.txt:211 (include)

-- Configuring incomplete, errors occurred!
See also "/home/nabilmiri/fatrop/build/CMakeFiles/CMakeOutput.log".

What possibly may be the problem?

Nabil-Miri commented 10 months ago

Dear Lander I have tried again different solutions but nothing has worked until now. Hope to get a feedback and things works fine soon. Thanks for your time.

lvanroye commented 10 months ago

Could you first try compiling without python?

cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DWITH_SPECTOOL=ON -DWITH_PYTHON=OFF

Nabil-Miri commented 10 months ago

UPDATE: I have skipped the python installation (removed pybind from submodule) as I want to use only spectool and C++.

I had a small problem but it was fixed: Output of cmake has found casadi: -- Found CasADi include dir: /usr/local/include -- Found CasADi libs: /usr/local/lib/libcasadi.so -- CASADI_INCLUDE_DIR is /usr/local/include -- Configuring done -- Generating done -- Build files have been written to: /home/nabilm/fatrop/build

But when I ./example of the spectool I got: nabilm@lur10:~/fatrop/build/fatrop/spectool$ ./example ./example: error while loading shared libraries: libcasadi.so.3.7: cannot open shared object file: No such file or directory

But adding: nabilm@lur10:~/fatrop/build/fatrop/spectool$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Fixed it.

Nabil-Miri commented 10 months ago

Could you first try compiling without python?

cmake .. -DBLASFEO_TARGET=X64_AUTOMATIC -DWITH_SPECTOOL=ON -DWITH_PYTHON=OFF

Oh yes same as what I did and it worked.

Thanks a lot for the help. I will try to use fatrop in our repo and hope all will work.

BTW if you are interested in an optimization based robot trajectory planner, feel free to check our repo: https://github.com/rst-tu-dortmund/mhp4hri

lvanroye commented 10 months ago

Interesting!! Curious how it will perform!