MongoDB C驱动程序Windows无法解析的外部符号

zxlwwiss  于 2023-01-08  发布在  Go
关注(0)|答案(3)|浏览(125)

嘿,伙计们,我希望这不是一个重复的,但已经搜索,并没有发现类似的问题。
我正在尝试使用Visual Studio在Windows 7 64位上构建MongoDB C驱动程序,如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

我做了完全相同的事情,但是在为libmongoc构建ALL_BUILD.vcxproj时,我得到了未解决的外部符号,尝试了很多东西,但仍然到达了这个死胡同。

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

...
先谢了!

8ehkhllq

8ehkhllq1#

修好了,用过了

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

代替

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

uqdfh47h2#

默认情况下,mongoc会根据OpenSSL(如果有的话)编译。在这种情况下,报告的OpenSSL版本似乎被破坏了,因为问题中的代码只在检测到OpenSSL 1.0.2或更高版本时才运行:https://github.com/mongodb/mongo-c-driver/blob/1.5.5/src/mongoc/mongoc-stream-tls-openssl.c#L641-L656我很好奇你们有哪个OpenSSL版本?
mongoc也支持其他TLS库,例如原生的Windows安全通道。
在mongoc 2.0中(当我们可以更改ABI/API时),我们打算将默认值从OpenSSL更改为平台原生实现(Windows安全通道,macOS安全传输),而不是默认为OpenSSL。LibreSSL(libtls)也受支持,并将在找到时使用。
配置要使用的TLS库是按照上面提到的注解完成的,将-DENABLE_SSL=WINDOWS传递给cmake(或用于macOS安全传输的达尔文)。

ujv3wf0j

ujv3wf0j3#

在程序中定义MONGOC_STATIC

相关问题