I’m working on a multithreaded multi-platform Qt-based program that uses libssh2. The program was occasionally crashing inside crypt_encrypt() and libssh2_transport_write() when several SSH-using threads were active at once, so I googled around and found some pages that say that for multithreaded libssh2 to work reliably, I need to call CRYPTO_set_locking_callback(), etc, before using libssh2.
Based on that advice I added the specified callback-setup calls to the top of main() and got it all to compile and run without crashing under MacOS/X… but under Windows I now get the following link errors that I’m not sure how to fix.
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Linking…
main.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function “void __cdecl do_crypto_locks_setup(void)” (?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_malloc referenced in function “void __cdecl do_crypto_locks_setup(void)” (?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function “void __cdecl do_crypto_locks_setup(void)” (?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_free referenced in function “void __cdecl do_crypto_locks_cleanup(void)” (?do_crypto_locks_cleanup@@YAXXZ)
Does anyone have an idea about what I might need to do in order to link these calls under Windows? Is there some other .lib file I need to link in, or do I need to pass a particular flag to the “perl Configure VC-WIN32” command to enable these functions, or ???
Thanks,
Jeremy
I’m not sure if this can help, but this link:
http://www.lurklurk.org/linkers/linkers.html
list some diferences between linking on unixes and windows
An excerpt:
__declspec(dllexport) int my_exported_function(int x, double y);
What would be left is to ask the MacOSX devs to search for those functions and tell you which specific library has those functions, recheck the code, redeclare if you can and try again.
Sorry that I could not pin point exactly what is your problem.
Also keep in mind that Visual Studio is a C++ compiler, not a C compiler, and while it is almost C90 compliant, the libssh libraries or others could use some C99 constructs which VS does not support.
I hope this can somehow help you to find your way.