SNOPT Integration in CasADi and SWIG Build Process

21 views
Skip to first unread message

Ruturaj Sambhus

unread,
Sep 14, 2024, 7:38:12 PM9/14/24
to SNOPT
Hello,

I am currently working on integrating SNOPT with CasADi and MATLAB for my project, but I have encountered several issues during the build and configuration process. I would appreciate your guidance in resolving these problems.

Context:
I am using the following configuration for my environment:
- **System:** Ubuntu 22.04 (x86_64)
- **MATLAB:** R2023b installed at `/usr/local/MATLAB/R2023b`
- **CasADi:** Compiled from source
- **SNOPT:** Using version 7, with SNOPT include and library files specified
- **SWIG:** Custom branch `matlab-customdoc` from the SWIG repository

Issues Encountered:

1. SWIG Compilation Issues:
   During the build of SWIG, I encountered an error related to `libpcre.so.1`, which seems to be missing from the path. After resolving that issue, SWIG could not recognize MATLAB, even though I specified the `--with-matlab` flag during configuration.
   
   Additionally, there is an error when I try to build with SWIG. It throws the following error:
   
   ```
   swig error : Unrecognized option -matlab
   Use 'swig -help' for available options.
   ```
   It appears that SWIG is not properly identifying the MATLAB installation or is failing to support the `-matlab` option.

2. **Compiler Compatibility**:
   The SWIG branch `matlab-customdoc` has known issues with `gcc-8` and above, as the CasADi documentation recommends. However, I have faced difficulties in downgrading to `gcc-7` and `g++-7` as these packages are no longer available in my system's package repositories.

   Even after trying various solutions (manual installations, PPA usage, etc.), I still encounter issues in configuring SWIG with `gcc-7`. The error message is:
   
   ```
   C compiler cannot create executables
   ```

3. **CasADi-SNOPT Build**:
   When attempting to build CasADi with SNOPT, the `CMake` configuration seems to partially find the SNOPT libraries, but the linking process appears to fail. Here is the command I am using:
   
   ```bash
   cmake -DWITH_SNOPT=ON -DSNOPT_INCLUDE_DIR=/home/trec/WorkRaj/raisim_legged/libsnopt7/include -DSNOPT_LIBRARY=/home/trec/WorkRaj/raisim_legged/libsnopt7/lib/libsnopt7_cpp.so -DWITH_MATLAB=ON -DMATLAB_ROOT=/usr/local/MATLAB/R2023b ../
   ```
   CMake output indicates that SNOPT is found but certain features in CasADi related to SNOPT are still disabled. This leads to errors when trying to invoke SNOPT functionality.

Key Questions:
1. Are there any specific SWIG-MATLAB compatibility fixes or alternative methods to bypass the `-matlab` option error?
2. Does SNOPT officially support newer versions of GCC (i.e., `gcc-8`), or is it mandatory to use older versions such as `gcc-7`? If so, is there a recommended procedure for ensuring successful downgrades on Ubuntu 22.04?
3. Could you advise on how best to resolve the linking issues with SNOPT in the CasADi configuration?

Any advice, patches, or additional documentation you could provide would be greatly appreciated. I am eager to proceed with this integration and could use your insights on the best path forward.

Thank you for your time and support.

Best regards,  
Ruturaj Sambhus


Reply all
Reply to author
Forward
0 new messages