spook / sshping

ssh-based ping: measure character echo latency and bandwidth
Other
284 stars 43 forks source link

MacOS - linking help with libssh? #23

Open Ralithune opened 4 years ago

Ralithune commented 4 years ago

Hi - could someone help me with library linking? After installing libssh with brew install libssh, trying to make sshping throws the error that the file isn't found.

[-2020-06-27 12:49:26 ~/git/sshping $> make
Scanning dependencies of target sshping
[ 33%] Building CXX object CMakeFiles/sshping.dir/src/sshping.cxx.o
/Users/mtippie/git/sshping/src/sshping.cxx:35:10: fatal error: 'libssh/libssh.h' file not found
#include <libssh/libssh.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/sshping.dir/src/sshping.cxx.o] Error 1
make[1]: *** [CMakeFiles/sshping.dir/all] Error 2
make: *** [all] Error 2
[-2020-06-27 12:49:27 ~/git/sshping $>

I altered sshping.cxx to make sure #define LIBSSH_STATIC 1 was run even outside the ifdef / else statement (as some googling suggested) but that seems to have no effect on the error.

Any help would be appreciated.

OlegSmelov commented 4 years ago

I was able to build sshping for macOS 10.14 by installing libssh with Homebrew and removing /usr/include/libssh/libssh.h from this line:

https://github.com/spook/sshping/blob/1456348e40c07dcec6f0019404e0aeae89d4d4fa/Makefile#L9

I didn't use cmake, just regular old make.

casouri commented 2 years ago

For those who uses macports, install libssh and use this Makefile. Basically adding -I/opt/local/include and -L/opt/local/lib.

# See https://github.com/spook/sshping

.PHONY=default sshping man
CFLAGS=-I/opt/local/include -Iext -L/opt/local/lib -lssh

default: sshping

sshping: bin/sshping

bin/sshping: src/sshping.cxx
    g++ -Wall -o bin/sshping $(CFLAGS) src/sshping.cxx

man: doc/sshping.8.gz

doc/sshping.8.gz: doc/sshping.8
    gzip -9cn $< > $@

doc/sshping.8: doc/sshping.pod
    if command -v pod2man &> /dev/null; then \
      pod2man --section=8 -c "ssh-based ping test utility" -d 2018-03-13 -r v0.1.4 doc/sshping.pod doc/sshping.8; \
    else \
      echo '*** Please install pod2man so that we can create the man page'; \
      exit 2; \
    fi
hexacera commented 2 years ago

For Apple Silicon the paths are these ones instead:

CFLAGS=-I /opt/homebrew/include -I ext -L /opt/homebrew/lib -lssh

Remember to add $(CFLAGS) to the g++ line though!

alshdavid commented 1 year ago

For Apple Silicon the paths are these ones instead:

CFLAGS=-I /opt/homebrew/include -I ext -L /opt/homebrew/lib -lssh

Remember to add $(CFLAGS) to the g++ line though!

I'm not too familiar with building C projects. This is what I ran to compile the project on an Apple SIlicon MBP

brew install libssh
g++ -Wall -I /opt/homebrew/include -I ext -L /opt/homebrew/lib -o bin/sshping src/sshping.cxx -lssh