Subject: Re: static linking problem

Re: static linking problem

From: Dan Fandrich <>
Date: Mon, 18 Oct 2010 13:10:30 -0700

On Mon, Oct 18, 2010 at 08:56:46PM +0100, may nothing wrote:
> sorry but that doesn't work. libssh2.a is definitely present in /usr/local/lib.
> Surprisingly "pkg-config libssh2 --static" doesn't returns anything ...
> However, this is the farest I could get:
> root_at_server: /data/work > gcc -Wall -I/usr/include -I/usr/local/include
> /usr/local/lib/libssh2.a -static -lssh2 sftptest.c -o sftptest

The order of arguments makes a difference. Try this order:

 gcc -Wall -I/usr/include -I/usr/local/include -static sftptest.c -o sftptest /usr/local/lib/libssh2.a

and since you have already have -static there, this ought to work, too:

 gcc -Wall -I/usr/include -I/usr/local/include -static sftptest.c -o sftptest -lssh2

>>> Dan
Received on 2010-10-18