I'm working on an existing C++ project. We include libcurl as a static library, which we build from source. I'm trying to upgrade us from version 7.38.0 to version 7.61.1.
I downloaded curl-7.61.1.zip from here: https://curl.haxx.se/download/.
I made no modifications to the source and did not run any scripts that came with curl 7.61.1.
We have an existing VS solution we used for compiling curl 7.38.0, so I started from that and modified as needed for the new files in curl 7.61.1.
Everything compiled fine, however, when I try to link the compiled result into my project, I get the following errors:
1>libcurl.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp_CertOpenStore referenced in function schannel_connect_step1
1>libcurl.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp_CertOpenStore
1>libcurl.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function schannel_connect_step1
1>libcurl.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp_CertCloseStore
1>libcurl.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp_CertFindCertificateInStore referenced in function schannel_connect_step1
1>libcurl.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateContext referenced in function pkp_pin_peer_pubkey
1>libcurl.lib(schannel_verify.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateContext
1>libcurl.lib(schannel.obj) : error LNK2019: unresolved external symbol __imp_CryptStringToBinaryA referenced in function schannel_connect_step1
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertAddCertificateContextToStore referenced in function add_certs_to_store
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertGetNameStringA referenced in function verify_host
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CryptQueryObject referenced in function add_certs_to_store
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertCreateCertificateChainEngine referenced in function verify_certificate
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateChainEngine referenced in function verify_certificate
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertGetCertificateChain referenced in function verify_certificate
1>libcurl.lib(schannel_verify.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateChain referenced in function verify_certificate
1>C:\Users\CoffeeTableEspresso\project\win64-vs15\debug-mt\executable.exe : fatal error LNK1120: 12 unresolved externals
Has anyone run into similar issues before? Please let me know if I need to edit this with more info as well.
As Peter mentioned in a comment, I needed to link against windows libraries. In this case, linking against crypt32.lib solved the issue for me.
I am getting LNK2019 error from linking C++ code with the standard library C++ library. I need to know which libraries contain the functions:
is_c_termination_complete,
__acrt_initialize,
__acrt_uninitialize,
__acrt_uninitialize_critical,
__acrt_thread_attach,
__acrt_thread_detach
to include it in the linking process.
I am writing code in C++ with MS Visual Studio community 2017 and Intel Parallel studio xe 2019 update 1 to be integrated in 3rd party software. The 3rd party software provides a "make" option to compile the object files and link them together.
Compilation works fine, linking provides an issue.
The 3rd party software provides an entry to provide basic linker options in the form of a variable. The default options are as follows:
link_sl='LINK', '/nologo', '/NOENTRY', '/INCREMENTAL:NO', '/subsystem:console', '/machine:AMD64',
' /NODEFAULTLIB:LIBC.LIB', '/NODEFAULTLIB:LIBCMT.LIB','/DEFAULTLIB:OLDNAMES.LIB', '/DEFAULTLIB:LIBIFCOREMD.LIB', '/DEFAULTLIB:LIBIFPORTMD.LIB', '/DEFAULTLIB:LIBMMD.LIB', '/DEFAULTLIB:kernel32.lib', '/DEFAULTLIB:user32.lib', '/DEFAULTLIB:advapi32.lib','/FIXED:NO', '/dll','/def:%E', '/out:%U', '%F', '%A', '%L', '%B',
'oldnames.lib', 'user32.lib', 'ws2_32.lib', 'netapi32.lib','advapi32.lib',
'msvcrt.lib', 'vcruntime.lib', 'ucrt.lib']
This gives the following 11 errors when linking:
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_uninitialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_thread_detach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _is_c_termination_complete referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_detach referenced in function __scrt_dllmain_crt_thread_detach
Which basically means that I am not including all the necessary libraries.
I already found out that including the library 'libvcruntime.lib' in the options reduces the errors to 6. So, using:
link_sl='LINK', '/nologo', '/NOENTRY', '/INCREMENTAL:NO', '/subsystem:console', '/machine:AMD64',
' /NODEFAULTLIB:LIBC.LIB', '/NODEFAULTLIB:LIBCMT.LIB','/DEFAULTLIB:OLDNAMES.LIB', '/DEFAULTLIB:LIBIFCOREMD.LIB', '/DEFAULTLIB:LIBIFPORTMD.LIB', '/DEFAULTLIB:LIBMMD.LIB', '/DEFAULTLIB:kernel32.lib', '/DEFAULTLIB:user32.lib', '/DEFAULTLIB:advapi32.lib','/FIXED:NO', '/dll','/def:%E', '/out:%U', '%F', '%A', '%L', '%B',
'oldnames.lib', 'user32.lib', 'ws2_32.lib', 'netapi32.lib','advapi32.lib',
'msvcrt.lib', 'vcruntime.lib', 'ucrt.lib',**'libvcruntime.lib'**]
Results in:
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _is_c_termination_complete referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_detach referenced in function __scrt_dllmain_crt_thread_detach
Which other libraries do I need to include in the linking process to resolve these?
I have encountered exactly the same problem when working within the framework provided by this 3rd party software. Although I cannot answer directly the question for finding the libraries containing _is_c_termination_complete, I realised it is still possible to make your code work: simply adding a /FORCE flag to your link_sl flag list.
According to MSVC official documentation:
The /FORCE option tells the linker to create a valid .exe file or DLL even if a symbol is referenced but not defined or is multiply defined.
Therefore, LNK2019 error messages will not stop the linker producing the dll library which is critical for the 3rd party software to run. The linker messages would look like:
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _is_c_termination_complete referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_detach referenced in function __scrt_dllmain_crt_thread_detach
: warning LNK4088: image being generated due to /FORCE option; image may not run
msvcprt.lib(locale0_implib.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
This is certainly not a decant solution and is not guaranteed to be working in any case, however it worked for my codes at least.
I compiled CURL for windows to use in VS2017 as
shown in this video
Also i have defined CURL_STATICLIB in preprocessor in C/C++ configuration properties.
Actual project properties is as
But it get below unresolved symbol errors for LIBCURL only
1>mainfile.obj : error LNK2001: unresolved external symbol _curl_easy_init
1>mainfile.obj : error LNK2001: unresolved external symbol _curl_easy_setopt
1>mainfile.obj : error LNK2001: unresolved external symbol _curl_easy_perform
1>mainfile.obj : error LNK2001: unresolved external symbol _curl_easy_cleanup
Please help in resolving , it 5 hrs i have been trying to remove this :(
I hava a problem in using mongo-c-driver in VS2010.
I used mongo-c-driver-1.2.0/VS2010/Win7-64bit;
Follow the steps in API document, I got four lib files.(I used cmake and VS2010 to build)
bson-1.0.lib bson-static-1.0.lib mongoc-1.0.lib mongoc-static-1.0.lib
And in my test program ,I put follow #pragma comment:
#pragma comment(lib,"bson-1.0.lib")
#pragma comment(lib,"mongoc-1.0.lib")
#pragma comment(lib,"bson-static-1.0.lib")
#pragma comment(lib,"mongoc-static-1.0.lib")
But it return some link error said
error LNK2019: unresolved external symbol _mongoc_cleanup
error LNK2019:unresolved external symbol _mongoc_client_destroy,
error LNK2019: unresolved external symbol mongoc_database_destroy,
error LNK2019: unresolved external symbol _mongoc_collection_destroy,
error LNK2019: unresolved external symbol _bson_free,
error LNK2019: unresolved external symbol _bson_destroy,
error LNK2019: unresolved external symbol _mongoc_collection_insert,
error LNK2019: unresolved external symbol _bson_as_json,
error LNK2019: unresolved external symbol _mongoc_client_command_simple,
error LNK2019: unresolved external symbol _bcon_new,
error LNK2019: unresolved external symbol _bson_bcon_magic,
error LNK2019: unresolved external symbol _mongoc_client_get_collection,
error LNK2019: unresolved external symbol _mongoc_client_get_database,
error LNK2019: unresolved external symbol _mongoc_client_new,
error LNK2019: unresolved external symbol _mongoc_init
Does anyone have idea about this problem. TAT.
The setup:
I have successfully compiled DarkGDK, a library designed for use with DirectX SDK 2007 and VS 2008, in VS 2013 with DirectX SDK 2010. I replaced one of the component libraries with a custom dummy library to resolve DirectX conflicts. I was able to successfully compile all of these component libraries.
The Problem:
When I compile my project that makes use of the DarkGDK libraries in Release mode, everything works as expected. I do get an message box complaining that the binary was built without debug information, but my program runs. However, in Debug mode, I get a number of errors. Below find a sample that I believe represents the lot well:
1>convmdl.lib(ConvMDL.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl QuaternionSlerp(float const * const,float * const,float,float * const)" (?QuaternionSlerp##YAXQBMQAMM1#Z)
1>libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>system.lib(CSystemC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>system.lib(dxdiaginfo.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>convx.lib(ConvX.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>convmd3.lib(ConvMD3.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(CBSPTree.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(CCompiler.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(ProcessHSR.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>world.lib(Patch.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(Universe.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(cLightMaps.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(CSG.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>image.lib(CImageC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>animation.lib(CAnimation.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(DBOFormat.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>basic3D.lib(CObjectManagerC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>core.lib(RenderList.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>display.lib(CGfxC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>file.lib(CFileC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>sprites.lib(CSpriteManagerC.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>Debug\Weapon Creator 2 - Project Golden Girl.exe : fatal error LNK1120: 1 unresolved externals
I have been searching about this issue for a few days now. I have have checked all the projects' settings that belong to the DarkGDK library and my own project's settings. In Debug configuration they are all using "Multi-threaded Debug (/MTd)".
TL;DR
I am getting the above errors when attempting to compile a project in Debug configuration that uses the DarkGDK Library. All projects have the same Windows Library and C run time settings.
Thank you!
Edit: Errors changed to reflect Dauphic's contribution.
You're mixing debug and release runtimes.
__CrtDbgReportW only exists in the debug runtime. If it's unresolved, it means you're probably compiling using the release runtime, but one of your libraries is using the debug runtime. You have to recompile one or the other, so they both use the same version.
You can find the runtime property at Project Properties -> C/C++ -> Code Generation -> Runtime Library
For the unresolved ATL symbol, I believe you need to link atls.lib.