컴파일해서 잘 돌아가다가 bio 에 멀 쓰던가 하면 OPENSSL_Uplink(00509010,07): no OPENSSL_Applink
위와 같은 에러가 발생하여 사람 참~ 난감하게 만든다.
처음에는 저걸 해결하지 못해서, bio 쓰는 부분을 몽땅 털어버리는 무식한 노가다를 하기도 했었다.
혹시나 비슷한 에러로 고생하는 사람이 없도록 http://www.openssl.org/support/faq.html 에 나와 있는 내용중에
위 에러를 해결하기 위한 방법을 적어본다.
아래는 해당 사이트 원문이다.
결국은 프로그램을 설정할 때 스레드 모델을 아래 사항에 맞도록 설정해 주면 아주 미끈하게 잘 돌아간다 -_-;;;
디버깅 하느라 날려버린 내 아까운 시간 흐~~
2. I've compiled a program under Windows and it crashes: why?
This is usually because you've missed the comment in INSTALL.W32. Your application must link against the same version of the Win32 C-Runtime against which your openssl libraries were linked. The default version for OpenSSL is /MD - "Multithreaded DLL".
If you are using Microsoft Visual C++'s IDE (Visual Studio), in many cases, your new project most likely defaulted to "Debug Singlethreaded" - /ML. This is NOT interchangeable with /MD and your program will crash, typically on the first BIO related read or write operation.
For each of the six possible link stage configurations within Win32, your application must link against the same by which OpenSSL was built. If you are using MS Visual C++ (Studio) this can be changed by:
1. Select Settings... from the Project Menu. 2. Select the C/C++ Tab. 3. Select "Code Generation from the "Category" drop down list box 4. Select the Appropriate library (see table below) from the "Use run-time library" drop down list box. Perform this step for both your debug and release versions of your application (look at the top left of the settings panel to change between the two)Note that debug and release libraries are NOT interchangeable. If you built OpenSSL with /MD your application must use /MD and cannot use /MDd.Single Threaded /ML - MS VC++ often defaults to this for the release version of a new project. Debug Single Threaded /MLd - MS VC++ often defaults to this for the debug version of a new project. Multithreaded /MT Debug Multithreaded /MTd Multithreaded DLL /MD - OpenSSL defaults to this. Debug Multithreaded DLL /MDd
As per 0.9.8 the above limitation is eliminated for .DLLs. OpenSSL .DLLs compiled with some specific run-time option [we insist on the default /MD] can be deployed with application compiled with different option or even different compiler. But there is a catch! Instead of re-compiling OpenSSL toolkit, as you would have to with prior versions, you have to compile small C snippet with compiler and/or options of your choice. The snippet gets installed as <install-root>/include/openssl/applink.c and should be either added to your application project or simply #include-d in one [and only one] of your application source files. Failure to link this shim module into your application manifests itself as fatal "no OPENSSL_Applink" run-time error. An explicit reminder is due that in this situation [mixing compiler options] it is as important to add CRYPTO_malloc_init prior first call to OpenSSL.