cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: setup Issue with libssh2 libcurl and gcc

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 20 Jan 2012 01:53:25 -0800

On Thu, Jan 19, 2012 at 09:10:41PM +0100, maarten_at_goeiespullen.nl wrote:
> Again I burned two days getting libssh2 to work... Is there a simple
> manual/ how to. I simply can not get this to work.

There are lots of man pages and example programs, but I'm not aware of
a tutorial as such.

> After a lot of
> attemps I decided to rollout Ubuntu again over my laptop, so more plain
> then this I can not do. Here what I did. I installed a clean Ubuntu
> 11.10 distribution.
>
> then downloaded the libssh2 package
> ./configure
> make
> sudo make

You're missing the final step:

  sudo make install

Without that, your new libssh2 won't be usable.

> downloaded the sftp_write.c example and I tried to compile this with :
>
> gcc -lssh2 -L/home/itops/Downloads/libssh2/libssh2-1.3.0/src -Wall -g
> -O2 -o main sftp_write.c
> sftp_write.c:28: fatal error: libssh2_config.h: No such file or
> directory
> compilation terminated.

The proper way to compile with libssh2 (once you've installed it) is to
use pkg-config to determine the correct compiler flags to use. Assuming
that you installed libssh2 into the default location (/usr/local/)
you'd use a command like this to compile:

env PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \
gcc -Wall -g -O2 `pkg-config libssh2 --cflags --libs` -o main sftp_write.c

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-01-20