參考安裝完的說明檔,有提到該copy什麼東西到VC++的lib&include去,
但還得搞清楚,那些lib的後綴字是麼意思。
以下轉貼挺清楚了!!
I understand you want to use these functions in your code. You don't need to compile OpenSSL for that.
Install the package on your development machine (if developing for Windows, you can get the latest installer here). It will contain header files you need to include in your code (they will be in
c:\OpenSSL-Win32\include\openssl
), static libraries you need to link your application against (in c:\OpenSSL-Win32\lib\VC
) and DLL your application needs to run (in c:\OpenSSL-Win32\bin
).
So, in your code you'll have:
#include <openssl/aes.h>
...
AES_set_encrypt_key(...);
...
AES_cfb128_encrypt(...);
...
Your compiler needs to know the path to header you included (path to
openssl
directory) so you need to provide it. If you are using Visual Studio, open project settings and add c:\OpenSSL-Win32\include
to Additional Include Directories.
In the Linker section, add
ssleay32MDd.lib;libeay32MDd.lib;
to Additional Dependencies so your linker know which OpenSSL libraries to look for. Path to these libraries - c:\OpenSSL-Win32\lib\VC
- add to Additional Library Directories.
Be careful with these libraries: they need to be linked against the same runtime library as your application. Their suffix tells you which runtime library they are linked against: libraries I mention above have suffix MDd which means they use Multi-threaded Debug DLL (/MDd) - so you will include them if your application use the same runtime (check this in Code Generation->Runtime Library setting).
Your application will build now but to run it, your binary will need to have access to OpenSSL DLL
libeay32.dll
as depends on it. Copy that DLL to system directory or to the directory you're running your app or add path c:\OpenSSL-Win32\bin
to Path
environment variable.http://stackoverflow.com/questions/7901683/how-to-compile-openssl-for-only-two-functions
沒有留言:
張貼留言