4

I compiled curl after cloning the repo using the following commands:

./buildconf
./configure --with-libssh2
make
sudo make install

However, after sudo make install, if

  • I run curl -V, I get: bash: /usr/bin/curl: No such file or directory.
  • I run /usr/local/bin/curl -V, I get: /usr/local/bin/curl: symbol lookup error: /usr/local/bin/curl: undefined symbol: curl_mime_type.

I tried getting around this by adding the path to curl/src to my PATH variable, and that made the curl command work from the terminal for my user. But if I try installing php-curl, apache understandably doesn't see curl and installs a different one.

Any ideas on how I can fix this?

Edit: The other post referred to in the comments was asking where to find the executable after compiling. That part was answered. But I still can't get curl to work without adding an entry to my PATH variable, which doesn't seem right. That's the part I'm trying to figure out now.

Fábio Correia
  • 595
  • 7
  • 16
Erich
  • 499
  • 1
  • 13
  • 34
  • Possible duplicate of [where is executable after compiling curl?](https://stackoverflow.com/questions/50846512/where-is-executable-after-compiling-curl) – Eddy Pronk Jun 18 '18 at 00:22
  • Since the post you're referring to is about where to find the curl executable, I thought that this warranted a separate post. This one is about the error I get after installing. – Erich Jun 18 '18 at 13:28
  • In my bounty post, I should have said the configure command I did: ./configure --with-libssh2. I should also mention that the way I installed libssh2 was with sudo apt-get install libssh2-1-dev. – Erich Jun 18 '18 at 20:51
  • 1
    run `ldd $(which curl)` , what do you get? – hanshenrik Jun 19 '18 at 00:13
  • When I run that command, I get: not a dynamic executable – Erich Jun 20 '18 at 13:21
  • Actually, when I ran that, which curl was pointing to the one in my path (curl/src). Now that I've removed that from my path, ldd $(which curl) returns: linux-vdso.so.1 => (0x00007fffd51ef000) libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007ff996851000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff996634000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff996415000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff996035000) libssh2.so.1 => /usr/lib/x86_64-linux-gnu/libssh2.so.1 (0x00007ff995e09000) [trimmed to fit this coment] – Erich Jun 20 '18 at 13:50
  • @Erich run `type curl`, and `which curl` and `file $(which curl)` , what do you get – hanshenrik Jun 20 '18 at 19:52
  • You should use `command -v curl`, not `which`. Also see [How to check if a program exists from a Bash script?](https://stackoverflow.com/q/592620/608639) and [How to check if command exists in a shell script?](https://stackoverflow.com/q/7522712/608639) – jww Jun 25 '18 at 10:33
  • In addition to `./configure --with-libssh2`, you should add `-L/usr/local/lib -Wl,-R,/usr/local/lib -Wl,--enable-new-dtags` to your `LDFLAGS` to avoid the path problems that have plagued Linux for the last two decades. – jww Jun 25 '18 at 10:36

1 Answers1

12

install path

If you don't use configure's --prefix option, the default installation will happen in /usr/local so curl ends up at /usr/local/bin/curl.

symbol lookup error

The symbol it reports to be missing is a recent addition to libcurl, which indicates that you're invoking a new curl tool that loads and uses an older libcurl - ie not the one you just installed but one from a previous (system?) install.

You can verify which libcurl your curl loads by invoking

$ ldd /usr/local/bin/curl | grep libcurl

You can change which libcurl your curl loads in one of several way, neither of which is curl specific so I'll just briefly mention the methods here to be further explained elsewhere:

  1. Just set LD_LIBRARY_PATH in the shell before you invoke curl
  2. Edit /etc/ld.so.conf and make sure the order of the search path makes the new libcurl gets found before the old one.
  3. Link your curl executable with a hard coded path to the new libcurl by invoking configure with something like LDFLAGS=-Wl,-R/usr/local/ssl/lib ./configure ...

replacing the system library?

It is generally not advised to replace the system installed libcurl with your custom build. Mostly because you might have an application or two that depend on specifics of that build. When you install your own libcurl from source, it is generally better to keep it installed in a separate path so that it can co-exist with the one already installed in your syste,.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
  • 1
    Thank you so much Daniel for the detailed answer. When I run the command you mentioned (ldd /usr/local/bin/curl | grep libcurl), I get: libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4. So if I go with option 2, I'm guessing I'd add "/usr/lib/x86_64-linux-gnu" to /etc/ld.so.conf. With that, should I be able to install php-curl as I normally would using apt-get install php-curl and apache will be able to work with it? Also, is there something I did wrong with the install that caused this behavior? Should I have uninstalled libcurl first perhaps? – Erich Jun 21 '18 at 18:31
  • It is sad Linux still has not fixed the broken path problem after 25 years or so. – jww Jun 25 '18 at 10:30
  • It's not a bug, it's a feature. This is not really a "path problem" to fix for "Linux". – Daniel Stenberg Jun 25 '18 at 10:43
  • Thanks for the info, Daniel. This worked! Enjoy a piece of my fragile reputation! – Erich Jun 25 '18 at 19:53
  • Why can't I download with curl? [@localhost]$ curl https://github.com/tensorflow/tensorflow/archive/v2.3.0.tar.gz You are being redirected.[@localhost]$ – fisakhan Sep 08 '20 at 15:58
  • [@localhost]$ which curl /usr/bin/curl [@localhost]$ ldd /usr/bin/curl | grep libcurl libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007fc60a6f7000) [@localhost]$ curl --version curl 7.72.0 (x86_64-redhat-linux-gnu) libcurl/7.72.0 NSS/3.44 zlib/1.2.7 libpsl/0.7.0 (+libicu/50.1.2) libssh2/1.9.0 nghttp2/1.33.0 Release-Date: 2020-08-19 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink ... – fisakhan Sep 08 '20 at 15:59