I'm working on a Visual Studio C++ project (my-demo
) and I've encountered a linking error that I can't seem to resolve. I've already ensured that all parts of my project and its dependencies use the /MT
option for the runtime library, but I'm still facing this error:
Severity: Error
Code: LNK2001
Description: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
Project: my-demo
File: C:\chime\build\main.obj
Line: 1
I am using Chime SDK for C++. https://d2ujn9kcsn2wox.cloudfront.net/windows/ChimeSdk-0.9.0-20230615-Windows-Release.zip
Followed All instructions as mentioned in the windows_setup guide. https://github.com/aws/amazon-chime-sdk-cpp/blob/main/guides/setup_windows.md
below is my main.cc file.
#include "utils/logger/console_logger.h"
#include <iostream>
#include <memory>
int main(int argc, char* argv[]) {
std::unique_ptr<chime::Logger> logger = std::make_unique<chime::ConsoleLogger>(chime::LogLevel::kVerbose);
}
Here's what I've tried so far:
- Ensured that the
/MT
(Static Runtime Library) option is set for both Debug and Release configurations. - Checked that all my dependencies and third-party libraries are compiled with
/MT
or/MTd
. - Cleaned and rebuilt the solution several times.
Yet, the error persists. I suspect that it might be related to how the libraries are linked or some inconsistencies in the build settings, but I'm not sure.
Could someone provide insights into this error and suggest potential solutions or things to check? I would appreciate any guidance.
Build Log:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x86\link.exe /ERRORREPORT:QUEUE /OUT:"C:\chime\build\Release\my-demo.exe" /INCREMENTAL:NO /NOLOGO "..\lib\bin\libamazon-chime-sdk.lib" crypt32.lib secur32.lib strmiids.lib winmm.lib msdmo.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /NODEFAULTLIB:LIBCMT /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/chime/build/Release/my-demo.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/chime/build/Release/my-demo.lib" /MACHINE:X86 /SAFESEH "my-demo.dir\Release\main.obj"
libcpmt.lib(locale.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) [C:\chime\build\my-demo.vcxproj]
libcpmt.lib(wlocale.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) [C:\chime\build\my-demo.vcxproj]
libcpmt.lib(xlocale.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) [C:\chime\build\my-demo.vcxproj]
There are 308 errors which are similar to above.
Solved this issue. Sharing here for everyone's reference
Below is what I did to build it.
- Removed LIBCMT from Ignore Specific Default Libraries. Although the Document asks to put it, but removing it worked.
- When using cmake -A Win32 .. as per document to generate the vcxproj file, following was getting added automatically: %(IgnoreSpecificDefaultLibraries). Had to remove this as well.
- In Linker-> Input -> Additonal Dependencies: Added %(AdditionalDependencies) to inherit from parent or project defaults. Along with other libs specified in Document.