嘗試1,香草鏈接庫上編譯和鏈接的Ubuntu VS的OpenSSL OSX
我試圖使用OpenSSL的修補版本(所以DTL上更容易使用)。 OpenSSL是在
/usr/local/openssl-1.0.1c
的./include/openssl子文件夾中有一噸的頭文件(因爲我認爲它應該):
lrwxrwxrwx 1 root root 22 Dec 25 05:49 aes.h -> ../../crypto/aes/aes.h
lrwxrwxrwx 1 root root 24 Dec 25 05:49 asn1.h -> ../../crypto/asn1/asn1.h
lrwxrwxrwx 1 root root 28 Dec 25 05:49 asn1_mac.h -> ../../crypto/asn1/asn1_mac.h
...
GCC鏈接到包含文件夾,並給了我一個錯誤 - 它找不到SSL。我使用或多或少的the same thing other people are。這工作,在OSX(10.6),但不是在Ubuntu:
~$ gcc -L/usr/local/openssl-1.0.1c/include -lssl -lcrypto -o server server.c
server.c:20:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
嘗試2,符號鏈接庫在/ usr /包括
所以,後來我嘗試創建符號鏈接到的OpenSSL在我的/ usr/include目錄:
sudo ln -s /usr/local/openssl-1.0.1c/include/openssl /usr/include/openssl
,並重新嘗試編譯:
~$ gcc -L/usr/local/openssl-1.0.1c/include -lssl -lcrypto -o server server.c
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: ld returned 1 exit status
make: *** [server] Error 1
爲什麼第一種方法(即沒有符號鏈接)不起作用?權限?爲什麼第二種方法不起作用?爲什麼在OSX上工作?