user2759923
user2759923

Reputation: 51

libssh symbols not found error gcc

I am trying to build a simple SSH client from Wil Allsopp's pen testing book. Working on Mac OS High Sierra with gcc-4.2 with libssh installed using Homebrew. The simplest version of the code is:

#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{    
    ssh_session my_ssh_session;
    my_ssh_session = ssh_new();
    ssh_free(my_ssh_session);
    return 0;
}

However a simple gcc build (gcc -Wall ssh_client.c) produces the following error:

Undefined symbols for architecture x86_64:

"_ssh_free", referenced from: _main in ssh_client-aa8f09.o

"_ssh_new", referenced from: _main in ssh_client-aa8f09.o

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1

Can anyone explain these errors and how I can fix them?

Upvotes: 0

Views: 679

Answers (1)

Paul Childs
Paul Childs

Reputation: 230

Your build line doesn't appear to contain any include and linker flags. I imagine it is picking up the headers but not the library for ssh to link against. Have a look into pkgconfig for an easy way to maintain this.

Upvotes: 0

Related Questions