Running C++ code using GSL in MATLAB on windows 11?

17 views (last 30 days)
Hi everyone,
I am trying to run an externally built c++ code through matlab (v2022b and v2023a) on windows, but I can't get it to complile. When I run codegen the build fails with the following errors:
  • 15 Could not find include file <gsl/gsl_math.h>
  • 15 Could not find include file <gsl/gsl_test.h>
  • 15 Could not find include file <gsl/gsl_ieee_utils.h>
  • 15 Could not find include file <gsl/gsl_poly.h>
I can't figure out how to install the gsl package onto a windows machine. Has anyone been able to do this? Any recommendations on how to get this working would be amazing.
Thank you very much,
Matt
  2 Comments
Shubham
Shubham on 3 Apr 2023
Hi Matthew,
The issue concerns the missing GSL (GNU Scientific Library) header files required by your C++ code. You need to download and install the GSL library on your Windows machine to resolve this issue.
Here are the steps to install the GSL library on Windows:
  1. Download the GSL library for Windows from the official website: https://www.gnu.org/software/gsl/
  2. Extract the downloaded archive to a folder on your computer. For example, you can extract it to "C:\gsl-2.7".
  3. Set the environment variable "GSL_DIR" to the path where the GSL library is installed. For example, if you extracted the GSL library to "C:\gsl-2.7", then set the environment variable "GSL_DIR" to "C:\gsl-2.7".
  4. Add the GSL library path to the system PATH environment variable. For example, if you extracted the GSL library to "C:\gsl-2.7", then add "C:\gsl-2.7\bin" to the system PATH environment variable.
After completing these steps, try running the codegen command again and see if the GSL header file errors are resolved. If you still face issues, you can try adding the GSL library path to the MATLAB path using the following command:
addpath('C:\gsl-2.7\include')
This should add the GSL library path to the MATLAB path and allow MATLAB to locate the required header files during code generation.
Maria Garcia
Maria Garcia on 30 Oct 2023
Hi! In what step should you install the GSL? I assume is after step 2. How can i do it on Windows? make command is not recognised

Sign in to comment.

Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!