在Debian 7.0中使用libcrypto用g ++编译c ++程序

时间:2016-02-01 20:32:32

标签: c++ g++

尝试使用g++进行编译时,我遇到了程序问题。这是命令:

root@server1:/home# g++ -o ssh2main ssh2main.cpp ssh2connect.cpp -static -lssh2 -L/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 -lcrypto -ldl -lz -Wno-write-strings;

这是我得到的输出:

/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status

我已经运行apt-get libcrypt*,我看到它已安装。

root@server1: locate crypt
/lib/libcryptsetup.so.4
/lib/libcryptsetup.so.4.2.0

...

/lib/x86_64-linux-gnu/libcrypt-2.19.so
/lib/x86_64-linux-gnu/libcrypt.so.1
/lib/x86_64-linux-gnu/libgcrypt.so.11
/lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
/lib/x86_64-linux-gnu/libgcrypt.so.20
/lib/x86_64-linux-gnu/libgcrypt.so.20.0.3

...

/var/lib/dpkg/info/cryptsetup-bin.list
/var/lib/dpkg/info/cryptsetup-bin.md5sums
/var/lib/dpkg/info/libcryptsetup4.list
/var/lib/dpkg/info/libcryptsetup4.md5sums
/var/lib/dpkg/info/libcryptsetup4.postinst
/var/lib/dpkg/info/libcryptsetup4.postrm
/var/lib/dpkg/info/libcryptsetup4.shlibs
/var/lib/dpkg/info/libcryptsetup4.symbols
/var/lib/dpkg/info/libgcrypt11:amd64.list
/var/lib/dpkg/info/libgcrypt11:amd64.md5sums
/var/lib/dpkg/info/libgcrypt11:amd64.postinst
/var/lib/dpkg/info/libgcrypt11:amd64.postrm
/var/lib/dpkg/info/libgcrypt11:amd64.shlibs
/var/lib/dpkg/info/libgcrypt11:amd64.symbols
/var/lib/dpkg/info/libgcrypt20-dev.list
/var/lib/dpkg/info/libgcrypt20-dev.md5sums
/var/lib/dpkg/info/libgcrypt20:amd64.list
/var/lib/dpkg/info/libgcrypt20:amd64.md5sums
/var/lib/dpkg/info/libgcrypt20:amd64.postinst
/var/lib/dpkg/info/libgcrypt20:amd64.postrm
/var/lib/dpkg/info/libgcrypt20:amd64.shlibs
/var/lib/dpkg/info/libgcrypt20:amd64.symbols
/var/lib/dpkg/info/libk5crypto3:amd64.list
/var/lib/dpkg/info/libk5crypto3:amd64.md5sums
/var/lib/dpkg/info/libk5crypto3:amd64.postinst
/var/lib/dpkg/info/libk5crypto3:amd64.postrm
/var/lib/dpkg/info/libk5crypto3:amd64.shlibs
/var/lib/dpkg/info/libk5crypto3:amd64.symbols

问题在于CentOS 5.5, 5.7它没有问题。我究竟做错了什么?我该如何解决这个问题?

感谢。

2 个答案:

答案 0 :(得分:2)

您看到的是GNU的libcrypt,而不是libcrypto

安装libssl-dev包。我假设ubuntu中的包名称和debian是相同的。否则,您需要为您的平台安装相应的ssl-dev pkg

答案 1 :(得分:0)

/usr/bin/ld: cannot find -lcrypto    
  

我已经运行了apt-get libcrypt *,我发现它已安装。

尝试-lcrypt

我还注意到链接路径目录没有-L。默认设置中的路径是否正确?