MATLAB Answers

Why does running the UNIX "curl" command from within MATLAB result in an error?

47 views (last 30 days)
Using the "curl" command within MATLAB's "system" function may cause an error such as the following:
>> [A,cURL_out] = system('curl')
A = 
cURL_out = 
dyld: Library not loaded: /opt/local/lib/libcurl.4.dylib 
Referenced from: /opt/local/bin/curl 
Reason: Incompatible library version: curl requires version 8.0.0 or 
later, but libcurl.4.dylib provides version 7.0.0
Another possible error is:
>> [A,cURL_out] = system('curl')
A = 
cURL_out =
curl: /usr/local/MATLAB/R2012a/bin/glnx86/ no version information available
(required by curl)
curl: (48) An unknown option was passed in to libcurl

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Oct 2021
Edited: MathWorks Support Team on 26 Oct 2021
The reason for this error is that MATLAB ships with its own “libcurl” file ("" on Linux and "libcurl.4.dylib" on macOS), which is incompatible with the system's “curl”.
This can be resolved by including the system's native "libcurl" library on the “LD_LIBRARY_PATH” environment variable (on Linux), or the "DYLD_LIBRARY_PATH" environment variable (on macOS). This variable is used by MATLAB to find shared libraries at runtime. Apply the following steps:
1)  First, find where the “curl” binary is located on your system by executing this command from a terminal:
$ which curl
2) Next, find the location of the compatible “libcurl” library for this "curl" command using the following command in the terminal:
where "CURL_PATH" is the path found in step 1. You can alternatively run the following command, if it is available on your system:
$ otool -L CURL_PATH
The output of the above command will provide a list of libraries used by the "curl" command and the locations of these libraries. Please note the location of the "" or “libcurl.4.dylib” file, on Linux and macOS, respectively. Note, to more easily find this library, try piping the output of the above command to the “grep” command like so: “ldd CURL_PATH | grep libcurl”.
3) Start MATLAB.
4) In MATLAB, set the “LD_LIBRARY_PATH” (Linux) or "DYLD_LIBRARY_PATH" (macOS) environment variable to include the location of "libcurl" found in step 2 (call this location LIBCURL_PATH) like so:
>> path1 = getenv('LD_LIBRARY_PATH') % Store existing path
>> path = [LIBCURL_PATH ':' path1] % Add compatible libcurl to path
>> setenv('LD_LIBRARY_PATH', path) % Set the path
You should now be able to use the “curl” command from within MATLAB. Please note that the environment variable changes made in step 4 will go away once you exit MATLAB. To retain these changes between MATLAB sessions, place the 3 lines of code in step 4 into MATLAB’s startup.m file. For more information about this file, please refer to the following link:
  1 Comment
jinye luo
jinye luo on 28 Nov 2021 at 5:43
Hi~, I set the system's native "libcurl" library on the “LD_LIBRARY_PATH” environment variable but still get the following error:
curl: /opt/MATLAB/R2021b/bin/glnxa64/ no version information available (required by curl)
1. find the location of the “libcurl” library
2. set the “LD_LIBRARY_PATH”:
3. Using the "curl" command within MATLAB
Curl asserted an error infomation but it got the correct 'html' page also(It was the same before I set system's native "libcurl" library on the “LD_LIBRARY_PATH” environment variable). I am really confused about it.
My environment:
  • Matlab 2021b
  • Ubuntu 20.04.3 LTS x86_64
Could you please tell me what the problem is?
Thank you in advance !

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!