Ubuntu mate ld cannot find -lcurl

Jan 13, 2018 by M. Zemmy Indrapatih

Recently i'm stuck when tried to make Delphi DataSnap Rest Server for linux using RadStudio 10.2.2. When i'm trying to compile the project on linux, delphi debug window show the following error:

[DCC Error] E2597 C:\Program Files (x86)\Embarcadero\Studio\19.0\bin\ld-linux.exe: error: cannot find -lcurl

Looking into ubuntu and try to install curl package from ubuntu repository using the following command:

user@mate64:~$ sudo apt-get install curl

but curl already installed with the following message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
curl is already the newest version (7.47.0-1ubuntu2.5).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.

Try to execute:

user@mate64:~$ ld -lcurl --verbose

return

attempt to open //usr/local/lib/x86_64-linux-gnu/libcurl.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libcurl.a failed
attempt to open //lib/x86_64-linux-gnu/libcurl.so failed
attempt to open //lib/x86_64-linux-gnu/libcurl.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libcurl.so failed
attempt to open //usr/lib/x86_64-linux-gnu/libcurl.a failed
attempt to open //usr/local/lib64/libcurl.so failed
attempt to open //usr/local/lib64/libcurl.a failed
attempt to open //lib64/libcurl.so failed
attempt to open //lib64/libcurl.a failed
attempt to open //usr/lib64/libcurl.so failed
attempt to open //usr/lib64/libcurl.a failed
attempt to open //usr/local/lib/libcurl.so failed
attempt to open //usr/local/lib/libcurl.a failed
attempt to open //lib/libcurl.so failed
attempt to open //lib/libcurl.a failed
attempt to open //usr/lib/libcurl.so failed
attempt to open //usr/lib/libcurl.a failed
attempt to open //usr/x86_64-linux-gnu/lib64/libcurl.so failed
attempt to open //usr/x86_64-linux-gnu/lib64/libcurl.a failed
attempt to open //usr/x86_64-linux-gnu/lib/libcurl.so failed
attempt to open //usr/x86_64-linux-gnu/lib/libcurl.a failed
ld: cannot find -lcurl

this means that libcurl.so not installed on requested path.

Try to locate the libcurl.so:

user@mate64:~$ locate libcurl.so

return

/usr/lib/x86_64-linux-gnu/libcurl.so.3
/usr/lib/x86_64-linux-gnu/libcurl.so.4
/usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0

I don't have libcurl.so installed. So i have to install:

user@mate64:~$ sudo apt-get install libcurl4-openssl-dev

Now after installing the libcurl4-openssl-dev package, if I execute:

user@mate64:~$ ld -lcurl --verbose

the ld can find the curl package

attempt to open //usr/local/lib/x86_64-linux-gnu/libcurl.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libcurl.a failed
attempt to open //lib/x86_64-linux-gnu/libcurl.so failed
attempt to open //lib/x86_64-linux-gnu/libcurl.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libcurl.so succeeded


Then the last step is to reload Delphi Linux SDK local cache:

npyscreenpreview
npyscreenpreview

Hope this guide can help anyone with the same issue as mine.