[CXX-1731] Cannot Build it on windows using static library Created: 09/Feb/19  Updated: 27/Oct/23  Resolved: 30/Mar/20

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: 3.4.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Ricardo Alcantara Assignee: Unassigned
Resolution: Gone away Votes: 2
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

1 -
Windows 10 x86_64
Visual Studio 2017 v141 Community 15.9.4
Windows SDK V - 10.0.17134.0
Scons


Attachments: Zip Archive VS-sample_msvc.zip     Zip Archive scons-mongo-cxx-sample.zip    
Issue Links:
Related
is related to CXX-1789 Issues using C++ driver in Visual Stu... Closed

 Description   

I built mongo-c for windows with static library with the following line:
 
cmake -G "Visual Studio 15 2017 Win64" "-DCMAKE_INSTALL_PREFIX=D:\mongo_driver\mongo_c_driver" "-DENABLE_SSL=WINDOWS" "-DCMAKE_PREFIX_PATH=D:\mongo_driver\mongo_c_driver" "-DENABLE_STATIC=ON" "-DENABLE_EXTRA_ALIGNMENT=OFF" ..

msbuild.exe /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj

msbuild.exe INSTALL.vcxproj

Then I build mongo-cxx for windows with static library too with:

cmake -G "Visual Studio 15 2017 Win64" "-DCMAKE_INSTALL_PREFIX=D:\mongo_driver\mongo_cxx_driver" "-DBSONCXX_POLY_USE_BOOST=1" "-DCMAKE_PREFIX_PATH=D:\mongo_driver\mongo_c_driver" "-DBUILD_SHARED_LIBS=OFF" "-DBOOST_ROOT=D:\mongo_driver\boost_1_69_0" ..

msbuild.exe ALL_BUILD.vcxproj

msbuild.exe INSTALL.vcxproj

After that I cannot build my VS Sample project neither my scons project

VS ouput

1>------ Build started: Project: sample_msvc, Configuration: Debug x64 ------
1>main.cpp
1>mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol DnsFree referenced in function _mongoc_get_rr_dnsapi
1>mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol DnsQuery_UTF8 referenced in function _mongoc_get_rr_dnsapi
1>mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol __imp_getaddrinfo referenced in function mongoc_client_connect_tcp
1>mongoc-static-1.0.lib(mongoc-topology-scanner.obj) : error LNK2001: unresolved external symbol __imp_getaddrinfo
1>mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol __imp_freeaddrinfo referenced in function mongoc_client_connect_tcp
1>mongoc-static-1.0.lib(mongoc-topology-scanner.obj) : error LNK2001: unresolved external symbol __imp_freeaddrinfo
1>mongoc-static-1.0.lib(mongoc-init.obj) : error LNK2019: unresolved external symbol __imp_WSAStartup referenced in function _mongoc_do_init
1>mongoc-static-1.0.lib(mongoc-init.obj) : error LNK2019: unresolved external symbol __imp_WSACleanup referenced in function _mongoc_do_cleanup
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __WSAFDIsSet referenced in function mongoc_socket_poll
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_accept referenced in function mongoc_socket_accept_ex
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_bind referenced in function mongoc_socket_bind
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_closesocket referenced in function mongoc_socket_close
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_connect referenced in function mongoc_socket_connect
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_ioctlsocket referenced in function _mongoc_socket_setnonblock
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getpeername referenced in function mongoc_socket_getnameinfo
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getsockname referenced in function mongoc_socket_getsockname
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getsockopt referenced in function mongoc_socket_connect
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_listen referenced in function mongoc_socket_listen
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function mongoc_socket_accept_ex
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_recv referenced in function mongoc_socket_recv
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_select referenced in function mongoc_socket_poll
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_send referenced in function _mongoc_socket_try_sendv_slow
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_setsockopt referenced in function mongoc_socket_setsockopt
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_shutdown referenced in function mongoc_socket_close
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_socket referenced in function mongoc_socket_new
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function mongoc_socket_poll
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSAIoctl referenced in function _mongoc_socket_setkeepalive_windows
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSASend referenced in function _mongoc_socket_try_sendv
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getnameinfo referenced in function mongoc_socket_getnameinfo
1>mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol inet_ntop referenced in function mongoc_socket_inet_ntop
1>mongoc-static-1.0.lib(mongoc-rand-cng.obj) : error LNK2019: unresolved external symbol BCryptOpenAlgorithmProvider referenced in function _mongoc_rand_bytes
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2001: unresolved external symbol BCryptOpenAlgorithmProvider
1>mongoc-static-1.0.lib(mongoc-rand-cng.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function _mongoc_rand_bytes
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptGetProperty referenced in function _mongoc_crypto_cng_hmac_or_hash
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptCloseAlgorithmProvider referenced in function mongoc_crypto_cng_cleanup
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptCreateHash referenced in function _mongoc_crypto_cng_hmac_or_hash
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptHashData referenced in function _mongoc_crypto_cng_hmac_or_hash
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptFinishHash referenced in function _mongoc_crypto_cng_hmac_or_hash
1>mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptDestroyHash referenced in function _mongoc_crypto_cng_hmac_or_hash
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol AcquireCredentialsHandleA referenced in function mongoc_stream_tls_secure_channel_new
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_FreeCredentialsHandle referenced in function _mongoc_stream_tls_secure_channel_destroy
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_FreeCredentialsHandle
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol InitializeSecurityContextA referenced in function _mongoc_stream_tls_secure_channel_destroy
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2001: unresolved external symbol InitializeSecurityContextA
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_DeleteSecurityContext referenced in function _mongoc_stream_tls_secure_channel_destroy
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_DeleteSecurityContext
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_ApplyControlToken referenced in function _mongoc_stream_tls_secure_channel_destroy
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol QueryContextAttributesA referenced in function _mongoc_stream_tls_secure_channel_write
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol QueryContextAttributesA
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol FreeContextBuffer referenced in function _mongoc_stream_tls_secure_channel_destroy
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2001: unresolved external symbol FreeContextBuffer
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol FreeContextBuffer
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol EncryptMessage referenced in function _mongoc_stream_tls_secure_channel_write
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol EncryptMessage
1>mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol DecryptMessage referenced in function _mongoc_stream_tls_secure_channel_decrypt
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol DecryptMessage
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptDecodeObjectEx referenced in function mongoc_secure_channel_setup_certificate_from_file
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertOpenStore referenced in function mongoc_secure_channel_setup_ca
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function mongoc_secure_channel_setup_ca
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertCreateCertificateContext referenced in function mongoc_secure_channel_setup_ca
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateContext referenced in function mongoc_secure_channel_setup_crl
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertSetCertificateContextProperty referenced in function mongoc_secure_channel_setup_certificate_from_file
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertAddCertificateContextToStore referenced in function mongoc_secure_channel_setup_ca
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertGetNameStringA referenced in function _bson_append_szoid
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptQueryObject referenced in function mongoc_secure_channel_setup_crl
1>mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptStringToBinaryA referenced in function mongoc_secure_channel_setup_ca
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_CryptStringToBinaryA
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_CryptBinaryToStringA referenced in function _mongoc_sspi_base64_encode
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_AcquireCredentialsHandleW referenced in function _mongoc_sspi_auth_sspi_client_init
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_InitializeSecurityContextW referenced in function _mongoc_sspi_auth_sspi_client_step
1>mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_QueryContextAttributesW referenced in function _mongoc_sspi_auth_sspi_client_step
1>bson-static-1.0.lib(bson-context.obj) : error LNK2019: unresolved external symbol __imp_gethostname referenced in function _bson_context_get_oid_host
1>D:\mongo_driver\sample_msvc\x64\Debug\sample_msvc.exe : fatal error LNK1120: 60 unresolved externals
1>Done building project "sample_msvc.vcxproj" – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Scons output:
$ scons platform=windows bits=64
Must use: x64 Native Tools Command Prompt for VS 2017

d:\mongo_driver\mongo-cxx-sample>scons platform=windows bits=64
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\main.obj /c src\main.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
main.cpp
cl /Fosrc\godot\gd_document_builder.obj /c src\godot\gd_document_builder.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_document_builder.cpp
cl /Fosrc\godot\gd_document_view.obj /c src\godot\gd_document_view.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_document_view.cpp
cl /Fosrc\godot\gd_mongodb.obj /c src\godot\gd_mongodb.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_mongodb.cpp
cl /Fosrc\godot\gd_mongodb_collection.obj /c src\godot\gd_mongodb_collection.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_mongodb_collection.cpp
cl /Fosrc\godot\gd_mongodb_connection.obj /c src\godot\gd_mongodb_connection.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_mongodb_connection.cpp
cl /Fosrc\godot\gd_mongodb_database.obj /c src\godot\gd_mongodb_database.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /DMONGOCXX_STATIC /DBSONCXX_STATIC /DMONGOC_STATIC /DBSON_STATIC /ID:\mongo_driver\boost_1_69_0 /ID:\mongo_driver\mongo_c_driver\include\libbson-1.0 /ID:\mongo_driver\mongo_c_driver\include\libmongoc-1.0 /ID:\mongo_driver\mongo_cxx_driver\include\mongocxx\v_noabi /ID:\mongo_driver\mongo_cxx_driver\include\bsoncxx\v_noabi /Isrc /Isrc\godot
gd_mongodb_database.cpp
link /nologo /OUT:bin\win64\sample.exe /LIBPATH:\mongo_driver\mongo_c_driver\lib /LIBPATH:\mongo_driver\mongo_cxx_driver\lib mongocxx-static.lib bsoncxx-static.lib mongoc-static-1.0.lib bson-static-1.0.lib src\main.obj src\godot\gd_document_builder.obj src\godot\gd_document_view.obj src\godot\gd_mongodb.obj src\godot\gd_mongodb_collection.obj src\godot\gd_mongodb_connection.obj src\godot\gd_mongodb_database.obj
mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol DnsFree referenced in function _mongoc_get_rr_dnsapi
mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol DnsQuery_UTF8 referenced in function _mongoc_get_rr_dnsapi
mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol __imp_getaddrinfo referenced in function mongoc_client_connect_tcp
mongoc-static-1.0.lib(mongoc-topology-scanner.obj) : error LNK2001: unresolved external symbol __imp_getaddrinfo
mongoc-static-1.0.lib(mongoc-client.obj) : error LNK2019: unresolved external symbol __imp_freeaddrinfo referenced in function mongoc_client_connect_tcp
mongoc-static-1.0.lib(mongoc-topology-scanner.obj) : error LNK2001: unresolved external symbol __imp_freeaddrinfo
mongoc-static-1.0.lib(mongoc-init.obj) : error LNK2019: unresolved external symbol __imp_WSAStartup referenced in function _mongoc_do_init
mongoc-static-1.0.lib(mongoc-init.obj) : error LNK2019: unresolved external symbol __imp_WSACleanup referenced in function _mongoc_do_cleanup
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_RegCloseKey referenced in function _mongoc_socket_setkeepalive_windows
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_RegOpenKeyExA referenced in function _mongoc_socket_setkeepalive_windows
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_RegQueryValueExA referenced in function _mongoc_socket_setkeepalive_windows
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __WSAFDIsSet referenced in function mongoc_socket_poll
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_accept referenced in function mongoc_socket_accept_ex
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_bind referenced in function mongoc_socket_bind
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_closesocket referenced in function mongoc_socket_close
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_connect referenced in function mongoc_socket_connect
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_ioctlsocket referenced in function _mongoc_socket_setnonblock
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getpeername referenced in function mongoc_socket_getnameinfo
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getsockname referenced in function mongoc_socket_getsockname
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getsockopt referenced in function mongoc_socket_connect
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_listen referenced in function mongoc_socket_listen
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function mongoc_socket_accept_ex
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_recv referenced in function mongoc_socket_recv
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_select referenced in function mongoc_socket_poll
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_send referenced in function _mongoc_socket_try_sendv_slow
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_setsockopt referenced in function mongoc_socket_setsockopt
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_shutdown referenced in function mongoc_socket_close
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_socket referenced in function mongoc_socket_new
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function mongoc_socket_poll
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSAIoctl referenced in function _mongoc_socket_setkeepalive_windows
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_WSASend referenced in function _mongoc_socket_try_sendv
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol __imp_getnameinfo referenced in function mongoc_socket_getnameinfo
mongoc-static-1.0.lib(mongoc-socket.obj) : error LNK2019: unresolved external symbol inet_ntop referenced in function mongoc_socket_inet_ntop
mongoc-static-1.0.lib(mongoc-rand-cng.obj) : error LNK2019: unresolved external symbol BCryptOpenAlgorithmProvider referenced in function _mongoc_rand_bytes
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2001: unresolved external symbol BCryptOpenAlgorithmProvider
mongoc-static-1.0.lib(mongoc-rand-cng.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function _mongoc_rand_bytes
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptGetProperty referenced in function _mongoc_crypto_cng_hmac_or_hash
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptCloseAlgorithmProvider referenced in function mongoc_crypto_cng_cleanup
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptCreateHash referenced in function _mongoc_crypto_cng_hmac_or_hash
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptHashData referenced in function _mongoc_crypto_cng_hmac_or_hash
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptFinishHash referenced in function _mongoc_crypto_cng_hmac_or_hash
mongoc-static-1.0.lib(mongoc-crypto-cng.obj) : error LNK2019: unresolved external symbol BCryptDestroyHash referenced in function _mongoc_crypto_cng_hmac_or_hash
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol AcquireCredentialsHandleA referenced in function mongoc_stream_tls_secure_channel_new
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_FreeCredentialsHandle referenced in function _mongoc_stream_tls_secure_channel_destroy
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_FreeCredentialsHandle
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol InitializeSecurityContextA referenced in function _mongoc_stream_tls_secure_channel_destroy
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2001: unresolved external symbol InitializeSecurityContextA
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_DeleteSecurityContext referenced in function _mongoc_stream_tls_secure_channel_destroy
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_DeleteSecurityContext
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_ApplyControlToken referenced in function _mongoc_stream_tls_secure_channel_destroy
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol QueryContextAttributesA referenced in function _mongoc_stream_tls_secure_channel_write
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol QueryContextAttributesA
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol FreeContextBuffer referenced in function _mongoc_stream_tls_secure_channel_destroy
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2001: unresolved external symbol FreeContextBuffer
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol FreeContextBuffer
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol EncryptMessage referenced in function _mongoc_stream_tls_secure_channel_write
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol EncryptMessage
mongoc-static-1.0.lib(mongoc-stream-tls-secure-channel.obj) : error LNK2019: unresolved external symbol DecryptMessage referenced in function _mongoc_stream_tls_secure_channel_decrypt
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol DecryptMessage
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptAcquireContextA referenced in function mongoc_secure_channel_setup_certificate_from_file
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptImportKey referenced in function mongoc_secure_channel_setup_certificate_from_file
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptDecodeObjectEx referenced in function mongoc_secure_channel_setup_certificate_from_file
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertOpenStore referenced in function mongoc_secure_channel_setup_ca
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function mongoc_secure_channel_setup_ca
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertCreateCertificateContext referenced in function mongoc_secure_channel_setup_ca
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateContext referenced in function mongoc_secure_channel_setup_crl
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertSetCertificateContextProperty referenced in function mongoc_secure_channel_setup_certificate_from_file
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertAddCertificateContextToStore referenced in function mongoc_secure_channel_setup_ca
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CertGetNameStringA referenced in function _bson_append_szoid
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptQueryObject referenced in function mongoc_secure_channel_setup_crl
mongoc-static-1.0.lib(mongoc-secure-channel.obj) : error LNK2019: unresolved external symbol __imp_CryptStringToBinaryA referenced in function mongoc_secure_channel_setup_ca
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2001: unresolved external symbol __imp_CryptStringToBinaryA
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_CryptBinaryToStringA referenced in function _mongoc_sspi_base64_encode
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_AcquireCredentialsHandleW referenced in function _mongoc_sspi_auth_sspi_client_init
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_InitializeSecurityContextW referenced in function _mongoc_sspi_auth_sspi_client_step
mongoc-static-1.0.lib(mongoc-sspi.obj) : error LNK2019: unresolved external symbol __imp_QueryContextAttributesW referenced in function _mongoc_sspi_auth_sspi_client_step
bson-static-1.0.lib(bson-context.obj) : error LNK2019: unresolved external symbol __imp_gethostname referenced in function _bson_context_get_oid_host
bin\win64\sample.exe : fatal error LNK1120: 65 unresolved externals
scons: *** [bin\win64\sample.exe] Error 1120
scons: building terminated because of errors.



 Comments   
Comment by Kevin Albertson [ 30/Mar/20 ]

Hi Tamara, apologies for the very delayed response. From your last comment it appears you have resolved your issue. If that is not the case, and this is still an issue for you, feel free to re-open.

Comment by Tamara Ockhuijsen [ 13/Dec/19 ]

Hi Ricardo,

The DNS errors went away when I added the following as additional dependency: Dnsapi.lib

These dependencies are all needed for the static library: bson-static-1.0.lib mongoc-static-1.0.lib bsoncxx-static.lib mongocxx-static.lib
ws2_32.lib Crypt32.lib Bcrypt.lib Secur32.lib Dnsapi.lib

I could not find this in the documentation, but found it in the comment here: https://jira.mongodb.org/browse/CXX-1789

More information can also be found on http://mongoc.org/libmongoc/current/visual-studio-guide.html under "Static linking", but Dnsapi.lib is missing here.

Comment by Tamara Ockhuijsen [ 03/Dec/19 ]

Hi C++ Driver team,

 

Is there any status update on this topic?

I'm having the same 2 link errors on Windows 10:

  • LNK2001 unresolved external symbol DnsFree
  • LNK2001 unresolved external symbol DnsQuery_UTF8

This happens after building my Visual Studio project using mongo-cxx 3.4.0 with the static library. My setup is almost the same as Ricardo's, only difference is using "Visual Studio 14 2015 Win64" and boost 1.64.0.

Currently in need of upgrading our C++ driver to version 3.4.0 or higher, to be compatible with MongoDB 4.0.

 

Thanks in advance.

Generated at Wed Feb 07 22:03:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.