Search code examples
c++windowsclangraylib

What standard libraries do I need to link to use Raylib with Windows and Clang?


I am trying to compile some C++ code with Clang; I am using Raylib. In an attempt to get things working, I have the basic window demo. All my Raylib header files are in a folder called "include" and my libraries are in a folder called "lib". After making sure I was including "include/raylib.h" and linking raylib.lib with the compiler arguments L.\lib -lraylib, I find an error message telling me 136 functions are yet to be defined, along with a bunch of other errors telling me exactly which functions this error is referring to:

fatal error LNK1120: 136 unresolved externals

After doing some digging, I find that linking some standard libraries gets this total down to 38.

Library Functions Defined
Gdi32.lib 13
WinMM.lib 2
User32.Lib 79
shell32.lib 4

OpenGL32.lib does not resolve any unresolved externals.

After copying in a more complex example (specifically, the "custom uniform" example), I see that the number of unresolved externals increases to 44. I assume that other examples will cause this number to increase to different amounts.

Here is the command that is used to compile the application currently:

clang++ main.cpp -o main.exe -L.\lib -lraylib -lOpenGL32 -lGdi32 -lWinMM -lUser32 -lshell32 -Xlinker /NODEFAULTLIB:MSVCRT

The /NODEFAULTLIB:MSVCRT linker argument is added because Clang warned me about function redefinitions.

The following are the logs that Clang outputs upon executing this command:

LINK : warning LNK4217: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'sprintf'
LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'raylib.lib(rtext.obj)'
LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'raylib.lib(rglfw.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'raylib.lib(rglfw.obj)'
LINK : warning LNK4217: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'CompressData'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'raylib.lib(rtext.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'raylib.lib(utils.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'raylib.lib(rglfw.obj)'
LINK : warning LNK4217: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'ClearDirectoryFiles'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'raylib.lib(rtext.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'raylib.lib(utils.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4217: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'DecodeDataBase64'
LINK : warning LNK4286: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'raylib.lib(rtext.obj)'
LINK : warning LNK4286: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'raylib.lib(utils.obj)'
LINK : warning LNK4286: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4217: symbol '_errno' defined in 'libucrt.lib(errno.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'DirectoryExists'
LINK : warning LNK4217: symbol 'strncmp' defined in 'libucrt.lib(strncmp.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'glad_gl_find_core_gl'
LINK : warning LNK4286: symbol 'strncmp' defined in 'libucrt.lib(strncmp.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4286: symbol 'strncmp' defined in 'libucrt.lib(strncmp.obj)' is imported by 'raylib.lib(rglfw.obj)'
LINK : warning LNK4217: symbol 'strpbrk' defined in 'libucrt.lib(strpbrk.obj)' is imported by 'raylib.lib(rcore.obj)' in function 'GetDirectoryPath'
LINK : warning LNK4217: symbol 'qsort' defined in 'libucrt.lib(qsort.obj)' is imported by 'raylib.lib(rtext.obj)' in function 'stbrp_pack_rects'
LINK : warning LNK4286: symbol 'qsort' defined in 'libucrt.lib(qsort.obj)' is imported by 'raylib.lib(rglfw.obj)'
LINK : warning LNK4217: symbol 'exit' defined in 'libucrt.lib(exit.obj)' is imported by 'raylib.lib(utils.obj)' in function 'TraceLog'
LINK : warning LNK4217: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'raylib.lib(utils.obj)' in function 'TraceLog'
LINK : warning LNK4217: symbol 'fclose' defined in 'libucrt.lib(fclose.obj)' is imported by 'raylib.lib(utils.obj)' in function 'LoadFileData'
LINK : warning LNK4286: symbol 'fclose' defined in 'libucrt.lib(fclose.obj)' is imported by 'raylib.lib(rtextures.obj)'
LINK : warning LNK4217: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'raylib.lib(utils.obj)' in function 'TraceLog'
LINK : warning LNK4217: symbol 'strtol' defined in 'libucrt.lib(strtox.obj)' is imported by 'raylib.lib(rtextures.obj)' in function 'stbi__hdr_load'
LINK : warning LNK4217: symbol 'strtoul' defined in 'libucrt.lib(strtox.obj)' is imported by 'raylib.lib(rglfw.obj)' in function 'parseMapping'
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function sscanf_s
raylib.lib(rtext.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
raylib.lib(rglfw.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
raylib.lib(rglfw.obj) : error LNK2001: unresolved external symbol __imp_realloc
raylib.lib(rcore.obj) : error LNK2001: unresolved external symbol __imp_realloc
raylib.lib(rtext.obj) : error LNK2001: unresolved external symbol __imp_realloc
raylib.lib(utils.obj) : error LNK2001: unresolved external symbol __imp_realloc
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_realloc
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_srand referenced in function InitWindow
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_rand referenced in function GetRandomValue
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_system referenced in function OpenURL
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_strncpy referenced in function GetPrevDirectoryPath
raylib.lib(rtext.obj) : error LNK2001: unresolved external symbol __imp_strncpy
raylib.lib(rglfw.obj) : error LNK2001: unresolved external symbol __imp_strncpy
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_round referenced in function SetupFramebuffer
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_round
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_fmaxf referenced in function Vector3Max
raylib.lib(rshapes.obj) : error LNK2001: unresolved external symbol __imp_fmaxf
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_fminf referenced in function Vector3Min
raylib.lib(rshapes.obj) : error LNK2001: unresolved external symbol __imp_fminf
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp_roundf referenced in function GetFPS
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__time64 referenced in function InitWindow
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__stat64i32 referenced in function GetFileModTime
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__access referenced in function FileExists
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__findclose referenced in function DirectoryExists
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__findfirst64i32 referenced in function opendir
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__findnext64i32 referenced in function GetDirectoryFiles
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__getcwd referenced in function GetWorkingDirectory
raylib.lib(rcore.obj) : error LNK2019: unresolved external symbol __imp__chdir referenced in function ChangeDirectory
raylib.lib(rtext.obj) : error LNK2019: unresolved external symbol __imp_toupper referenced in function TextToPascal
raylib.lib(rtext.obj) : error LNK2019: unresolved external symbol __imp_tolower referenced in function LoadFontFromMemory
raylib.lib(utils.obj) : error LNK2019: unresolved external symbol __imp_fopen referenced in function LoadFileData
raylib.lib(utils.obj) : error LNK2019: unresolved external symbol __imp_fread referenced in function LoadFileData
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_fread
raylib.lib(utils.obj) : error LNK2019: unresolved external symbol __imp_fseek referenced in function LoadFileData
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_fseek
raylib.lib(utils.obj) : error LNK2019: unresolved external symbol __imp_ftell referenced in function LoadFileData
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_ftell
raylib.lib(utils.obj) : error LNK2019: unresolved external symbol __imp_fwrite referenced in function SaveFileData
raylib.lib(rtextures.obj) : error LNK2001: unresolved external symbol __imp_fwrite
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_strtod referenced in function GenImageCellular
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_fmax referenced in function GenImageGradientRadial
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_fmin referenced in function GenImageCellular
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_frexp referenced in function stbiw__write_hdr_scanline
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_hypot referenced in function GenImageCellular
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_ldexp referenced in function stbi__hdr_convert
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_fopen_s referenced in function stbi_info
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_feof referenced in function stbi__stdio_eof
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_ferror referenced in function stbi__stdio_eof
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_fgetc referenced in function stbi__stdio_skip
raylib.lib(rtextures.obj) : error LNK2019: unresolved external symbol __imp_ungetc referenced in function stbi__stdio_skip
raylib.lib(rglfw.obj) : error LNK2019: unresolved external symbol __imp_strcspn referenced in function glfwUpdateGamepadMappings
raylib.lib(rglfw.obj) : error LNK2019: unresolved external symbol __imp_strspn referenced in function glfwUpdateGamepadMappings
main.exe : fatal error LNK1120: 38 unresolved externals
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

I do not know which of the 481 other standard libraries I need to link in order to get my code to compile, or if there is some other trick needed to compile my code. Below is a list of all 486 standard libraries in question:

libucrt.lib  libucrtd.lib  ucrt.lib  ucrtd.lib


AclUI.Lib                          dciman32.lib              hbaapi.lib                           MqOA20.Tlb        ondemandconnroutehelper.lib  ShLwApi.Lib            Wer.lib
ActiveDS.Lib                       dcomp.lib                 hhsetup.lib                          MqRt.Lib          OneCore.Lib                  simpdata.tlb           wevtapi.lib
ADSIid.Lib                         ddraw.lib                 hid.lib                              MrmSupport.lib    OneCore_apiset.Lib           slc.lib                WiaGuid.Lib
AdvAPI32.Lib                       devenum.lib               HLink.Lib                            msaatext.lib      OneCore_downlevel.Lib        slcext.lib             wiaservc.lib
advpack.Lib                        deviceaccess.lib          hrtfapo.lib                          MSAcm32.Lib       OneCoreUAP.Lib               slwga.lib              wiautil.lib
ahadmin.lib                        devmgr.lib                Htmlhelp.Lib                         MSAJApi.lib       OneCoreUAP_apiset.Lib        SnmpAPI.Lib            WinBio.lib
amsi.lib                           dflayout.lib              httpapi.lib                          msclus.tlb        OneCoreUAP_downlevel.Lib     spoolss.lib            windows.ai.machinelearning.lib
amstrmid.lib                       DhcpCSvc.Lib              hxhelppaneproxy.tlb                  Mscms.Lib         OpenGL32.Lib                 SpOrder.Lib            windows.data.pdf.lib
apidll.lib                         DhcpCSvc6.Lib             iashlpr.lib                          MsCtfMonitor.lib  osptk.lib                    SrClient.lib           windows.media.mediacontrol.lib
appmgmts.lib                       dhcpsapi.lib              Icm32.Lib                            msdasc.lib        p2p.lib                      srpapi.lib             windows.networking.lib
appmgr.lib                         DiagnosticDataQuery.Lib   Icmui.Lib                            msdatsrc.tlb      p2pgraph.lib                 ssdpapi.lib            windows.ui.lib
appnotify.lib                      dinput8.lib               icu.lib                              msdelta.lib       patchwiz.lib                 StdOle2.Tlb            WindowsApp.lib
ASycFilt.Lib                       directml.lib              icuin.Lib                            msdmo.lib         pathcch.lib                  Sti.Lib                WindowsApp_downlevel.lib
audiobaseprocessingobject.lib      dloadhelper.lib           icuuc.lib                            msdrm.lib         Pdh.Lib                      strmbase.lib           windowscodecs.lib
AudioBaseProcessingObjectV140.lib  dmoguids.lib              IEPMAPI.Lib                          msfeeds.tlb       PeerDist.lib                 strmiids.lib           windowscoreheadless.Lib
audioeng.lib                       dmprocessxmlfiltered.lib  iesetup.lib                          Msi.Lib           PhotoAcquireUID.lib          strsafe.lib            windowscoreheadless_apiset.Lib
audiomediatypecrt.lib              DnsAPI.Lib                iextag.tlb                           MSImg32.Lib       PortableDeviceGuids.lib      structuredquery.lib    windowssideshowguids.lib
AuthZ.Lib                          dnscrcli.lib              ImageHlp.Lib                         mspatcha.lib      powrprof.lib                 Svcguid.Lib            winfax.lib
aux_ulib.lib                       dnslib.lib                imapi2.tlb                           mspatchc.lib      prntvpt.lib                  swdevice.lib           winhttp.lib
avifil32.Lib                       dnsperf.lib               imapi2fs.tlb                         mspbase.lib       ProjectedFSLib.lib           synchronization.lib    WinInet.Lib
avrt.lib                           dnsrpc.lib                imgutil.Lib                          msports.lib       propsys.lib                  t2embed.lib            winml.lib
basesrv.lib                        dnsrslvr.lib              Imm32.Lib                            MSRating.Lib      Psapi.Lib                    Tapi32.Lib             WinMM.Lib
bcrypt.lib                         dpx.lib                   infocardapi.Lib                      MSTask.Lib        quartz.lib                   tapi32l.lib            winsatapi.lib
Bits.Lib                           drt.lib                   inkobjcore.lib                       msv1_0.lib        query.lib                    taskschd.lib           winscard.lib
BluetoothApis.lib                  drtprov.lib               inseng.lib                           msvfw32.Lib       qwave.lib                    tbs.lib                WinSpool.Lib
bthprops.lib                       drttransport.lib          int64.lib                            MsWSock.Lib       RASAPI32.Lib                 tdh.lib                winsqlite3.lib
BufferOverflow.lib                 dsound.lib                iphlpapi.lib                         MsXml.Tlb         RASDlg.Lib                   Thunk32.Lib            winsta.lib
BufferOverflowU.lib                DSProp.Lib                Iprop.Lib                            MsXml2.Lib        rasuser.lib                  tokenbinding.lib       WinStrm.Lib
Cabinet.Lib                        dssec.lib                 iscsidsc.lib                         msxml6.lib        Rdcentraldb.tlb              Traffic.Lib            WinTrust.Lib
certadm.lib                        dststlog.lib              IsolatedWindowsEnvironmentUtils.lib  Mtx.Lib           rdpencomapi.tlb              TranscodeImageUID.lib  winusb.lib
certca.lib                         DSUIExt.Lib               jetoledb.lib                         mtxdm.lib         rendezvoussession.tlb        tsec.lib               wkspbkax.tlb
certcli.lib                        DtcHelp.Lib               jsrt.lib                             muiload.lib       resutils.lib                 tspubplugincom.lib     wlanapi.lib
CertIdl.Lib                        dwmapi.lib                kerbcli.lib                          ncrypt.lib        rometadata.lib               tsuserex.tlb           wlanui.lib
CertPolEng.Lib                     dwrite.lib                kernel32.Lib                         nddeapi.lib       rpcexts.lib                  twain_32.lib           Wldap32.Lib
cfgmgr32.lib                       dxcompiler.lib            kernel32legacylib.lib                ndfapi.lib        Rpcns4.Lib                   twinapi.lib            Wldp.Lib
Chakrart.lib                       dxcore.lib                keycredmgr.lib                       ndproxystub.lib   rpcproxy.lib                 txfw32.lib             wmcodecdspuuid.lib
cimfs.lib                          dxgi.lib                  KSProxy.Lib                          NetAPI32.Lib      RpcRT4.Lib                   ualapi.lib             wmip.lib
cldapi.lib                         dxguid.lib                ksuser.lib                           NetFW.TLB         rpcutil.lib                  UIAutomationCore.lib   wmiutils.lib
clfsmgmt.lib                       dxtmsft.lib               ktmw32.lib                           netlib.lib        rstrtmgr.lib                 umpdddi.lib            wmvcore.lib
clfsw32.lib                        dxtrans.lib               LoadPerf.Lib                         NetSh.Lib         Rtm.Lib                      unicows.lib            wofutil.lib
ClusApi.Lib                        dxva2.lib                 locationapi.lib                      newdev.lib        rtutils.lib                  Urlmon.Lib             workspace.tlb
ComCtl32.Lib                       eappcfg.lib               Lz32.Lib                             ninput.lib        RTWorkQ.lib                  User32.Lib             workspaceax.lib
ComDlg32.Lib                       eappprxy.lib              magnification.lib                    normaliz.lib      runtimeobject.lib            UserEnv.Lib            workspaceruntime.tlb
CompPkgSup.lib                     easregprov.lib            MAPI32.Lib                           nt.lib            samlib.lib                   USP10.Lib              Wow32.Lib
compstui.lib                       efswrt.lib                mbnapi.tlb                           ntdll.lib         samsrv.lib                   Uuid.Lib               WS2_32.Lib
ComSvcs.Lib                        ehstorguids.lib           mbnapi_uuid.lib                      ntdsa.lib         SAPI.Lib                     Uxtheme.lib            wsbapp_uuid.Lib
CoreMessaging.lib                  elfapi.lib                mciole32.lib                         NtDsAPI.Lib       sas.lib                      vccomsup.lib           wsbonline.lib
corrEngine.lib                     els.lib                   mdmlocalmanagement.lib               ntdsatq.lib       sbtsv.lib                    VdmDbg.Lib             wscapi.lib
Credui.lib                         ElsCore.lib               MDMRegistration.lib                  ntdsetup.lib      SCardDlg.Lib                 vds_uuid.lib           wsclient.lib
Crypt32.Lib                        esent.lib                 Mf.lib                               ntfrsapi.lib      scecli.lib                   Version.Lib            wsdapi.lib
cryptdll.lib                       evr.lib                   Mfcore.lib                           ntlanman.lib      scesrv.lib                   Vfw32.Lib              wsmandisp.tlb
CryptNet.Lib                       exdisp.tlb                Mfplat.lib                           ntmarta.lib       schannel.lib                 Virtdisk.Lib           wsmsvc.lib
cryptui.lib                        FaultRep.Lib              mfplay.lib                           NtQuery.Lib       ScrnSave.Lib                 vscmgr.lib             WSnmp32.Lib
cryptxml.lib                       faxcomex.tlb              mfreadwrite.lib                      ntstc_libcmt.lib  ScrnSavW.Lib                 vss_uuid.lib           WSock32.Lib
cscapi.lib                         feclient.lib              mfsensorgroup.lib                    ntstc_msvcrt.lib  SearchAPI.tlb                vssapi.lib             WtsApi32.Lib
cscdll.lib                         FhSvcCtl.lib              Mfsrcsnk.lib                         ntvdm.lib         SearchSDK.lib                vstorinterface.lib     wuguid.lib
d2d1.lib                           fileextd.lib              mfuuid.lib                           objsel.lib        Secur32.Lib                  wbemuuid.lib           xapobase.lib
d3d10.lib                          fltLib.lib                MgmtAPI.Lib                          odbc32.lib        security.lib                 wcmapi.lib             xapobase2_8.lib
d3d10_1.lib                        fontsub.lib               mi.lib                               odbcbcp.lib       sens.lib                     wcmguid.lib            xaswitch.lib
d3d11.lib                          FrameDyd.Lib              mincore.lib                          odbccp32.lib      SensAPI.Lib                  wdsbp.lib              xaudio2.lib
d3d12.lib                          FrameDyn.Lib              mincore_downlevel.lib                OemLicense.lib    SensEvts.Tlb                 wdsClientAPI.LIB       xaudio2_8.lib
d3d9.lib                           fwpuclnt.lib              MMC.Lib                              Ole32.Lib         sensorsapi.lib               wdsmc.lib              xinput.lib
d3dcompiler.lib                    fxsutility.lib            mmdevapi.lib                         OleAcc.Lib        SensorsUtils.lib             wdspxe.lib             Xinput9_1_0.lib
d3dcsx.lib                         Gdi32.Lib                 Mpr.Lib                              OleAut32.Lib      SetupAPI.Lib                 wdstptc.lib            xinputuap.lib
d3dcsxd.lib                        gdiplus.lib               Mprapi.Lib                           olecli32.lib      Sfc.Lib                      WdsTptMgmt.tlb         xmllite.lib
davclnt.lib                        glmf32.lib                mprsnap.lib                          oledb.lib         shcore.lib                   webauthn.lib           xolehlp.lib
DbgEng.Lib                         GlU32.Lib                 MqOA.Lib                             OleDlg.Lib        shdocvw.lib                  WebServices.lib        xpsdocumenttargetprint.lib
DbgHelp.Lib                        GPEdit.lib                mqoa.tlb                             OlePro32.Lib      shell32.lib                  websocket.lib          xpsprint.lib
DbgModel.Lib                       gpmuuid.lib               MqOA10.Tlb                           olesvr32.lib      ShFolder.Lib                 wecapi.lib

The first four are separated from the rest because they are in a different folder.

How do I get my code to compile properly and display the basic window example?


Solution

  • Context

    I did some digging regarding what happens when you use the Raylib for Windows installer to compile your program. As it turns out, when building a program using the included instance of Notepad++, it literally shows you what it does. For some reason, the compiled program was mistakenly flagged as malicious by Microsoft Defender Antivirus, saying it contained Trojan:Script/Wacatac.B!ml. This caused a scare which caused me to tell Windows to delete the falsely-flagged trojan, however, it was accidentally flagged twice, causing Windows to think it was unsuccessful on the second try, which prompted me to perform a Microsoft Defender Offline scan. Once everything was sorted, and I realized what had happened, I did some digging regarding what Notepad++ told me it did, and from there I was able to extract the missing libraries.

    Answer

    As it turned out, msvcrt.lib, the same library I was excluding some default functions from due to conflicts, was one of them. The other was kernel32.lib. When including these libraries, my program successfully compiled, although a new library, libcmt.lib, created some new conflicts. If any new compiler errors pop up regarding unresolved externals, try linking libcmt.lib and omitting the linker argument /NODEFAULTLIB:libcmt. If any other conflicts like this pop up, and there are new unresolved externals, try linking the library that causes the conflicts.

    The following is the command I used to successfully compile the basic window example using Raylib with Windows and Clang.

    clang++ main.cpp -o main.exe -L.\lib -lmsvcrt -lraylib -lOpenGL32 -lGdi32 -lWinMM -lkernel32 -lshell32 -lUser32 -Xlinker /NODEFAULTLIB:libcmt
    

    Footnotes

    If you're building for production and don't want a console window to pop up with debug messages, put #define main WinMain somewhere in your code because WinMain is the entry point for Windows applications instead of main. You don't need to specify the /SUBSYSTEM:WINDOWS linker argument.

    I apologize for not including some of the other libraries on my PC in my big list of libraries in my question, which were in another folder on my PC. Among these libraries were libcmt.lib and the missing msvcrt.lib.