[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Link static


Hi,

pass '-static' flag to the compiler.

Also, '-L' is to specify directory, while '-l' is to specify library so
'-L/usr/lib64/ -lssh' is what you would want.

'/usr/' and '/usr/local' directories are searched by default by
gcc/clang, so '-lssh -static' should get you going.

Regards,
Petar

On May 20, 11:16, Cristian Saavedra wrote:
> Hi
>
> I'm trying to link static the ssh library, I'm using the following command
>
> g++ -o ssh ssh.cpp -L/usr/lib64/libssh.a -lssh
>
> I also defined #define LIBSSH_STATIC 1 on the source code
>
> However it is still linking the dynamic library
> ldd ssh
>         libssh.so.4 => /usr/lib64/libssh.so.4 (0x00002b20ad027000)
>         libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000033d6800000)
>         libm.so.6 => /lib64/libm.so.6 (0x00000033c3600000)
>         libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000033d3400000)
>         libc.so.6 => /lib64/libc.so.6 (0x00000033c3200000)
>         librt.so.1 => /lib64/librt.so.1 (0x00000033c4600000)
>         libssl.so.6 => /lib64/libssl.so.6 (0x0000003173000000)
>         libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00000033cda00000)
>         libz.so.1 => /usr/lib64/libz.so.1 (0x00000033c4200000)
>         libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2
> (0x000000319ee00000)
>         libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x000000319ea00000)
>         libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x000000319fa00000)
>         libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00000033cca00000)
>         /lib64/ld-linux-x86-64.so.2 (0x00000033c2e00000)
>         libpthread.so.0 => /lib64/libpthread.so.0 (0x00000033c3e00000)
>         libdl.so.2 => /lib64/libdl.so.2 (0x00000033c3a00000)
>         libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0
> (0x000000319e600000)
>         libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00000033cea00000)
>         libresolv.so.2 => /lib64/libresolv.so.2 (0x00000033cd600000)
>         libselinux.so.1 => /lib64/libselinux.so.1 (0x000000319f600000)
>         libsepol.so.1 => /lib64/libsepol.so.1 (0x000000319e200000)
>
>
> Any help would be greatly appreciate
>
>
> Best Regards,
> Cristian Saavedra

--
Regards,
Petar

Follow-Ups:
Re: How to Link staticCristian Saavedra <cristianpsg@xxxxxxxxx>
References:
How to Link staticCristian Saavedra <cristianpsg@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org