I'm writing a C program that uses libssh. My program consists of ext.h and c1.h. I compiled them to ext.o and c1.o and I'm trying to link these files. My libssh dylib files are at
SSHLIB = -L/usr/local/Cellar/libssh/0.6.3_2/lib
So in my Makefile, I'm trying to execute
clang -o c1 ext.o c1.o $(SSHLIB)
However, it prompts lots of errors like
Undefined symbols for architecture x86_64:
"_ssh_connect", referenced from:
_ext in ext.o
"_ssh_disconnect", referenced from:
_ext in ext.o
"_ssh_free", referenced from:
_ext in ext.o
I tried to look at the directory SSHLIB, and tried to
nm -gU libssh.dylib
I can see it contains lots of functions, including like _ssh_connect and _ssh_disconnect. Why does Clang fail to link them? How can I fix it?