The reason for this error is that MATLAB ships with its own “libcurl” file ("libcurl.so.4" 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:
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:
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 "libcurl.so.4" 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')
>> path = [LIBCURL_PATH ':' path1]
>> setenv('LD_LIBRARY_PATH', 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: