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

Statically linking


I am sure I am doing something stupid but I can not see it at the moment.

I build the latest libssh with WITH_STATIC_LIB=ON set.

This is my CMakeList.txt:

set(SOURCE_FILES
> TestSSHClient.cpp
> )
>
> add_executable(testSSHClient ${SOURCE_FILES} ${HEADER_FILES})
> find_package( Threads )
> add_definitions (-DLIBSSH_STATIC)
> add_library(libssh STATIC IMPORTED)
> set_property(TARGET libssh PROPERTY IMPORTED_LOCATION
> /usr/local/lib/libssh.a)
> include_directories(/usr/local/include)
> target_link_libraries(testSSHClient libssh)


This is my cpp file:

>  #define LIBSSH_STATIC 1
> #include <libssh/libssh.h>
> #include <stdlib.h>
>
>
> int main()
> {
> ssh_session my_ssh_session;
> int verbosity = SSH_LOG_PROTOCOL;
> int port = 22;
> my_ssh_session = ssh_new();
> if (my_ssh_session == NULL)
> exit(-1);
> ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
> ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
> ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
> ssh_free(my_ssh_session);
> }


I am getting tons of error messages about undefined reference like these:

> /usr/local/lib/libssh.a(pki.c.o): In function `ssh_key_clean':
> /home/paul.beerkens/Downloads/libssh-0.8.7/src/pki.c:136: undefined
> reference to `DSA_free'
> /home/paul.beerkens/Downloads/libssh-0.8.7/src/pki.c:137: undefined
> reference to `RSA_free'
> /home/paul.beerkens/Downloads/libssh-0.8.7/src/pki.c:139: undefined
> reference to `EC_KEY_free'
> /usr/local/lib/libssh.a(pki.c.o): In function `ssh_signature_free':
> /home/paul.beerkens/Downloads/libssh-0.8.7/src/pki.c:505: undefined
> reference to `DSA_SIG_free'
> /home/paul.beerkens/Downloads/libssh-0.8.7/src/pki.c:521: undefined
> reference to `ECDSA_SIG_free'
> /usr/local/lib/libssh.a(wrapper.c.o): In function `crypto_free':
>


What do I need to do to get static linking to work?

Paul

Follow-Ups:
Re: Statically linkingMihai Moldovan <ionic@xxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org