Wallflips
Wallflips

Reputation: 78

MongoDB C Driver Windows unresolved external symbol

Hey guys I hope this is not a duplicate, but searched already and didn't find a similar question.

I'm trying to build MongoDB C Driver on windows 7 64bit using visual studio as described in http://mongoc.org/libmongoc/1.1.5/installing.html

cd mongo-c-driver-1.1.5\src\libbson
cmake -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver"
msbuild.exe ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

cd mongo-c-driver-1.1.5
cmake -G "Visual Studio 2010 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DBSON_ROOT_DIR=C:\mongo-c-driver"
msbuild.exe ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

I did absolutely the same but on building ALL_BUILD.vcxproj for libmongoc I got unresolved external symbols, tried a lot of stuff but still reaching this deadend.

Error   146 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-stream-tls-openssl.obj    mongoc_shared
Error   274 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-load
Error   359 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-secondary
Error   443 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set-ssl
Error   527 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set
Error   611 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-sharded-cluster
Error   722 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_ip_asc referenced in function mongoc_stream_tls_openssl_new    C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-libmongoc
Error   144 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-stream-tls-openssl.obj    mongoc_shared
Error   272 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-load
Error   357 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-secondary
Error   441 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set-ssl
Error   525 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set
Error   609 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-sharded-cluster
Error   720 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set1_host referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-libmongoc
Error   145 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set_hostflags referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-stream-tls-openssl.obj    mongoc_shared
Error   273 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set_hostflags referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-load
Error   358 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set_hostflags referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-secondary
Error   442 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set_hostflags referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set-ssl
Error   526 error LNK2019: unresolved external symbol X509_VERIFY_PARAM_set_hostflags referenced in function mongoc_stream_tls_openssl_new  C:\Users\Airy\Desktop\mongo-c-driver-1.6.2\mongoc-static-1.0.lib(mongoc-stream-tls-openssl.obj) test-replica-set

...

Thanks in advance!

Upvotes: 0

Views: 496

Answers (3)

user3953129
user3953129

Reputation: 1

define MONGOC_STATIC in your program

Upvotes: 0

bjori
bjori

Reputation: 2104

By default mongoc will compile against OpenSSL if available. In this case, the reported OpenSSL version seems to be broken somehow as the code in questions only runs when it detects OpenSSL 1.0.2 and later: https://github.com/mongodb/mongo-c-driver/blob/1.5.5/src/mongoc/mongoc-stream-tls-openssl.c#L641-L656 I'm curious which OpenSSL version you have available?

mongoc also support other TLS libraries, such as the native Windows Secure Channel.

In mongoc 2.0 (when we can change the ABI/API) we intend to change the defaults from OpenSSL to the platform native implementations (Windows Secure Channel, macOS Secure Transport) rather then defaulting to OpenSSL. LibreSSL (libtls) is also supported and will be used when found.

Configuring which TLS library to use is done as the comment above mentions, passing -DENABLE_SSL=WINDOWS to cmake (or DARWIN for macOS Secure Transport).

Upvotes: 0

Wallflips
Wallflips

Reputation: 78

Fixed it, used

cmake -G "Visual Studio 14 2015 Win64" "-DENABLE_SSL=WINDOWS" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DBSON_ROOT_DIR=C:\mongo-c-driver"

instead of

cmake -G "Visual Studio 2010 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DBSON_ROOT_DIR=C:\mongo-c-driver"

Upvotes: 1

Related Questions