c++linkerclangglfwmsvcrt

I'm having troubles compiling c++ application with GLFW and vulkan libraries using clang. How can i solve this?


I'm trying to compile my c++ test application with GLFW and vulkan using clang on windows, but it fails every time. I get a lot of link errors and any of suggested solutions I could find didn't work. It seems the problem is with the GLFW library files, but I can't find a way to solve it.

Batch script I use for compiling my code:

REM Build script for the test application.
@ECHO OFF
SetLocal EnableDelayedExpansion

REM Get a list of all the .cpp files.
SET cFilenames=
FOR /R %%f in (*.cpp) do (
    SET cFilenames=!cFilenames!"%%f" 
)

SET assembly=test
SET compilerFlags=-g -std=c++17
REM Define what to include.
SET includeFlags=-Isrc -I../test/include -I%VULKAN_SDK%/Include -IE:/Libraries/GLFW/include -IE:/Libraries/json-3.11.2/include -IE:/Libraries/stb-master
REM Define what to link.
SET linkerFlags=-L%VULKAN_SDK%/Lib -lvulkan-1 -LE:/Libraries/GLFW/lib-vc2022 -lglfw3_mt
REM Define some extra stuff.
SET defines=-D_DEBUG

REM Build the project.
ECHO "Building %assembly%%..."
clang++ %cFilenames% %compilerFlags% -o ../bin/%assembly%.exe %defines% %includeFlags% %linkerFlags%

The errors I receive after I try to build the application:

"Building test..."
libcpmtd.lib(StlCompareStringA.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(StlLCMapStringA.obj) : error LNK2001: unresolved external symbol _malloc_dbg  
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(xwcsxfrm.obj) : error LNK2001: unresolved external symbol _malloc_dbg
main-929849.o : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(locale0.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(StlCompareStringA.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(StlLCMapStringA.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(xwcsxfrm.obj) : error LNK2001: unresolved external symbol _free_dbg
main-929849.o : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(locale0.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _CrtDbgReport
main-929849.o : error LNK2001: unresolved external symbol _CrtDbgReport
libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol _CrtDbgReport
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _CrtDbgReport
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _CrtDbgReport
libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
main-929849.o : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(_tolower.obj) : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _calloc_dbg
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_TranslateMessage referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_TranslateMessage
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_DispatchMessageW referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_DispatchMessageW
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_PeekMessageW referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_PeekMessageW
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_RegisterDeviceNotificationW referenced in function _glfwPlatformInit       
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_UnregisterDeviceNotification referenced in function _glfwPlatformTerminate
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_CreateWindowExW referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_CreateWindowExW
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_DestroyWindow referenced in function _glfwPlatformTerminate
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_DestroyWindow
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_ShowWindow referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_ShowWindow
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_ToUnicode referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_MapVirtualKeyW referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_MapVirtualKeyW
glfw3_mt.lib(win32_init.obj) : error LNK2019: unresolved external symbol __imp_SystemParametersInfoW referenced in function _glfwPlatformInit
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_SystemParametersInfoW
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_CreateDCW referenced in function _glfwPlatformGetGammaRamp
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_DeleteDC referenced in function _glfwPlatformGetGammaRamp
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetDeviceCaps referenced in function _glfwGetMonitorContentScaleWin32   
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetDeviceGammaRamp referenced in function _glfwPlatformGetGammaRamp
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_SetDeviceGammaRamp referenced in function _glfwPlatformSetGammaRamp     
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetDC referenced in function _glfwGetMonitorContentScaleWin32
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_GetDC
glfw3_mt.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __imp_GetDC
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_ReleaseDC referenced in function _glfwGetMonitorContentScaleWin32       
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_ReleaseDC
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_ChangeDisplaySettingsExW referenced in function _glfwPlatformGetVideoModes
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_EnumDisplaySettingsW referenced in function _glfwPlatformGetVideoMode   
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_EnumDisplaySettingsExW referenced in function _glfwPlatformGetMonitorPosglfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_EnumDisplayDevicesW referenced in function _glfwPollMonitorsWin32       
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetMonitorInfoW referenced in function _glfwPlatformGetMonitorWorkarea  
glfw3_mt.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp_GetMonitorInfoW
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_EnumDisplayMonitors referenced in function _glfwPollMonitorsWin32       
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateBitmap referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateRectRgn referenced in function updateFramebufferTransparency       
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DeleteObject referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateDIBSection referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_TrackMouseEvent referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetMessageTime referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SendMessageW referenced in function _glfwPlatformSetWindowIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_PostMessageW referenced in function _glfwPlatformPostEmptyEvent
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_WaitMessage referenced in function _glfwPlatformWaitEvents
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DefWindowProcW referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_UnregisterClassW referenced in function _glfwUnregisterWindowClassWin32  
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_RegisterClassExW referenced in function _glfwRegisterWindowClassWin32
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetLayeredWindowAttributes referenced in function _glfwPlatformGetWindowOpacity
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetLayeredWindowAttributes referenced in function _glfwPlatformSetWindowOpacity
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_FlashWindow referenced in function _glfwPlatformRequestWindowAttention
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_MoveWindow referenced in function _glfwPlatformSetWindowAspectRatio      
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetWindowPos referenced in function _glfwPlatformMaximizeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetWindowPlacement referenced in function createNativeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetWindowPlacement referenced in function createNativeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_IsWindowVisible referenced in function _glfwPlatformMaximizeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_IsIconic referenced in function _glfwPlatformWindowIconified
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_BringWindowToTop referenced in function _glfwPlatformCreateWindow        
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_IsZoomed referenced in function _glfwPlatformWindowMaximized
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_OpenClipboard referenced in function _glfwPlatformGetClipboardString     
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CloseClipboard referenced in function _glfwPlatformGetClipboardString    
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetClipboardData referenced in function _glfwPlatformSetClipboardString  
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetClipboardData referenced in function _glfwPlatformGetClipboardString  
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_EmptyClipboard referenced in function _glfwPlatformSetClipboardString    
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetFocus referenced in function _glfwPlatformCreateWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetActiveWindow referenced in function _glfwPlatformPollEvents
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetKeyState referenced in function _glfwPlatformPollEvents
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetCapture referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_ReleaseCapture referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_MsgWaitForMultipleObjects referenced in function _glfwPlatformWaitEventsTimeout
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetSystemMetrics referenced in function _glfwPlatformMaximizeWindow      
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetForegroundWindow referenced in function _glfwPlatformCreateWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetPropW referenced in function createNativeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetPropW referenced in function _glfwPlatformPollEvents
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_RemovePropW referenced in function _glfwPlatformDestroyWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetWindowTextW referenced in function _glfwPlatformSetWindowTitle        
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetClientRect referenced in function _glfwPlatformGetFramebufferSize     
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetWindowRect referenced in function _glfwPlatformSetWindowAspectRatio
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_AdjustWindowRectEx referenced in function _glfwPlatformGetWindowFrameSizeglfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetCursorPos referenced in function _glfwPlatformPollEvents
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetCursor referenced in function _glfwPlatformSetCursor
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetCursorPos referenced in function _glfwPlatformGetCursorPos
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_ClientToScreen referenced in function _glfwPlatformGetWindowPos
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_ScreenToClient referenced in function _glfwPlatformGetCursorPos
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_WindowFromPoint referenced in function cursorInContentArea
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_ClipCursor referenced in function updateClipRect
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetRect referenced in function _glfwPlatformGetWindowFrameSize
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_OffsetRect referenced in function _glfwPlatformMaximizeWindow
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_PtInRect referenced in function cursorInContentArea
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetWindowLongW referenced in function _glfwPlatformGetWindowOpacity      
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_SetWindowLongW referenced in function _glfwPlatformMaximizeWindow        
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetClassLongPtrW referenced in function _glfwPlatformSetWindowIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_LoadCursorW referenced in function _glfwPlatformSetCursor
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DestroyIcon referenced in function _glfwPlatformDestroyCursor
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_LoadImageW referenced in function _glfwPlatformCreateStandardCursor
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateIconIndirect referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_MonitorFromWindow referenced in function _glfwPlatformGetWindowContentScale
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_GetRawInputData referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_RegisterRawInputDevices referenced in function _glfwPlatformSetRawMouseMotion
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragQueryFileW referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragQueryPoint referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragFinish referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragAcceptFiles referenced in function createNativeWindow
glfw3_mt.lib(win32_joystick.obj) : error LNK2019: unresolved external symbol __imp_GetRawInputDeviceInfoA referenced in function deviceCallback
glfw3_mt.lib(win32_joystick.obj) : error LNK2019: unresolved external symbol __imp_GetRawInputDeviceList referenced in function deviceCallback
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_ChoosePixelFormat referenced in function _glfwInitWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_DescribePixelFormat referenced in function _glfwCreateContextWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_SetPixelFormat referenced in function _glfwCreateContextWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_SwapBuffers referenced in function swapBuffersWGL
libcpmtd.lib(_tolower.obj) : error LNK2019: unresolved external symbol _wcsdup_dbg referenced in function _Getctype
libcpmtd.lib(xstrcoll.obj) : error LNK2001: unresolved external symbol _wcsdup_dbg
libcpmtd.lib(locale.obj) : error LNK2019: unresolved external symbol _realloc_dbg referenced in function "private: static void __cdecl std::locale::_Locimp::_Locimp_Addfac(class std::locale::_Locimp *,class std::locale::facet *,unsigned __int64)" (?_Locimp_Addfac@_Locimp@locale@std@@CAXPEAV123@PEAVfacet@23@_K@Z)
libcpmtd.lib(StlLCMapStringA.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function _freea_crt
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
libcpmtd.lib(StlCompareStringA.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
..\bin\test.exe : fatal error LNK1120: 104 unresolved externals
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

Already tried to reinstall clang, MSVCRT and GLFW. I had some clear answers, when I asked the OpenAI chatbot, but it didn't solve my problem either. Any ideas how can I solve this problem?

EDIT

I managed to solve almost all of the errors, but I still get the GLFW unresolved external symbol error.

The updated batch script I use to compile the application:

REM Build script for the test application.
@ECHO OFF
SetLocal EnableDelayedExpansion

REM Get a list of all the .cpp files.
SET cFilenames=
FOR /R %%f in (*.cpp) do (
    SET cFilenames=!cFilenames!"%%f" 
)

SET assembly=test
SET compilerFlags=-g -std=c++17
REM Define what to include.
SET includeFlags=-Isrc -I../test/include -I%VULKAN_SDK%/Include -IE:/Libraries/GLFW/include -IE:/Libraries/json-3.11.2/include -IE:/Libraries/stb-master
REM Define what to link.
SET linkerFlags=-luser32 -L%VULKAN_SDK%/Lib -lvulkan-1 -LE:/Libraries/GLFW/lib-vc2022 -lglfw3_mt -lmsvcrtd -llibcmtd
REM Define some extra stuff.
SET defines=-D_DEBUG -Xlinker /NODEFAULTLIB:libcmt

REM Build the project.
ECHO "Building %assembly%%..."
clang++ %cFilenames% %compilerFlags% -o ../bin/%assembly%.exe %defines% %includeFlags% %linkerFlags%

The errors that still remain:

"Building test..."
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_CreateDCW referenced in function _glfwPlatformGetGammaRamp
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_DeleteDC referenced in function _glfwPlatformGetGammaRamp
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetDeviceCaps referenced in function _glfwGetMonitorContentScaleWin32   
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_GetDeviceGammaRamp referenced in function _glfwPlatformGetGammaRamp     
glfw3_mt.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol __imp_SetDeviceGammaRamp referenced in function _glfwPlatformSetGammaRamp     
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateBitmap referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateRectRgn referenced in function updateFramebufferTransparency
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DeleteObject referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_CreateDIBSection referenced in function createIcon
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragQueryFileW referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragQueryPoint referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragFinish referenced in function windowProc
glfw3_mt.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp_DragAcceptFiles referenced in function createNativeWindow
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_ChoosePixelFormat referenced in function _glfwInitWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_DescribePixelFormat referenced in function _glfwCreateContextWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_SetPixelFormat referenced in function _glfwCreateContextWGL
glfw3_mt.lib(wgl_context.obj) : error LNK2019: unresolved external symbol __imp_SwapBuffers referenced in function swapBuffersWGL
..\bin\test.exe : fatal error LNK1120: 17 unresolved externals
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

Any ideas?


Solution

  • I managed to solve this problem by including 6 libraries and excluding 1.

    For anyone who has the same problem as me, here is my batch script for compiling my code:

    REM Build script for the test application.
    @ECHO OFF
    SetLocal EnableDelayedExpansion
    
    REM Get a list of all the .cpp files.
    SET cFilenames=
    FOR /R %%f in (*.cpp) do (
        SET cFilenames=!cFilenames!"%%f" 
    )
    
    SET assembly=test
    SET compilerFlags=-g -std=c++17
    REM Define what to include.
    SET includeFlags=-Isrc -I../test/include -I%VULKAN_SDK%/Include -IE:/Libraries/GLFW/include -IE:/Libraries/json-3.11.2/include -IE:/Libraries/stb-master
    REM Define what to link.
    SET linkerFlags=-luser32 -lkernel32 -lgdi32 -lshell32 -L%VULKAN_SDK%/Lib -lvulkan-1 -LE:/Libraries/GLFW/lib-vc2022 -lglfw3_mt -lmsvcrtd -llibcmtd
    REM Define some extra stuff.
    SET defines=-D_DEBUG -Xlinker /NODEFAULTLIB:libcmt
    
    REM Build the project.
    ECHO "Building %assembly%%..."
    clang++ %cFilenames% %compilerFlags% -o ../bin/%assembly%.exe %defines% %includeFlags% %linkerFlags%