4

I can't compile, I use Ubuntu on Odroid-XU4 plate. How can I fix this problem? Thanks for any help.

odroid@odroid:~/Desktop/curl_test.2$ g++ -o postit2 postit2.c -lcurl
/tmp/cc4MoKQE.o: In function `main':
postit2.c:(.text+0x2c): undefined reference to `curl_mime_init'
postit2.c:(.text+0x36): undefined reference to `curl_mime_addpart'
postit2.c:(.text+0x48): undefined reference to `curl_mime_name'
postit2.c:(.text+0x56): undefined reference to `curl_mime_filedata'
postit2.c:(.text+0xfa): undefined reference to `curl_mime_free'
collect2: error: ld returned 1 exit status
odroid@odroid:~/Desktop/curl_test.2$ curl --version
curl 7.56.0 (armv7l-unknown-linux-gnueabihf) libcurl/7.47.0 
OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Release-Date: 2017-10-04
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps 
pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM 
NTLM_WB SSL libz TLS-SRP UnixSockets 
boriaz50
  • 860
  • 4
  • 17
  • Maybe you have another libcurl version installed too that g++ picks up when linking? It only warns on the API calls that are new in 7.56.0... – Daniel Stenberg Oct 05 '17 at 06:28
  • what should be done? I need to delete all version and try to install libcurl 7.56.0? – Евгений Сергеевич Oct 05 '17 at 07:01
  • You could do that; also you could install and build the Curl source for the version you want, but _not_ install it. Then have your program pick up the headers and static libraries for the new Curl version by specifying their actual filesystem locations in the new Curl build. The problem with installing a new Curl, if you have to build from source, is that it's very easy to end up building a version that lacks SSL support or some other useful feature. If you can get the version you want from your distribution, that's unlikely to be a problem; but your distro might not have that version. – Kevin Boone Oct 05 '17 at 07:39
  • Евгений Сергеевич, did you try some variants? – boriaz50 Oct 05 '17 at 13:25

2 Answers2

1
  1. Install the latest version of curl from sources. There is no need to remove your existing curl. The default configure will place the installation under /usr/local, but you can install under your home directory if you want and this doesn't require root privileges. The option to configure is --prefix=`.
  2. The compiler and the linker will both by default look in /usr/local. If you install to a different place, you have to tell the tols where. The compiler option would be -I<directory-to-install>/include and the linker option is -L<directory-to-install>/lib.
  3. If you use dynamic linking, you have to specify where your libraries will be at run time. The runtime loader will not normally look under /usr/local, so you have to specify it even if you install there. The relevant gcc option is -Wl,-rpath=<directory-where-libcurl.so-lives-at-run-time>. Unless you are compiling for a different machine, this is the same directory where libcurl.so is installed, so you might end up specifying the same directory twice, with -L and -Wl,-rpath options.
n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
0

Linker looks for libcurl in its configured path and it finds old version first.

Edit /etc/ld.so.conf to make the linker looks for in directory with new libculr version.

Or reinstall libcurl:

sudo apt-get remove libcurl
wget http://curl.haxx.se/download/curl-7.56.0.tar.gz
./configure
make
make install
boriaz50
  • 860
  • 4
  • 17
  • 1
    Don't mix software development and system administration. There is no need to touch your system installed software in order to develop your own. – n. m. could be an AI Oct 05 '17 at 20:25
  • You should. This is very important for libcurl in particular, as it has a zillion build time configuration parameters and optional dependencies. You don't want to end up with a sysyem where curl suddenly cannot do ssl or ftp or kerberos or ... – n. m. could be an AI Oct 05 '17 at 20:52
  • 1
    I have thought about it. In my opinion, developer should have basic administration skills. It lets to be less dependent and solve problems more quickly. – boriaz50 Oct 06 '17 at 18:34