简体   繁体   English

我需要链接哪些标准库才能将 Raylib 与 Windows 和 Clang 一起使用?

[英]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;我正在尝试用 Clang 编译一些 C++ 代码; I am using Raylib.我正在使用 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".我所有的 Raylib 头文件都在一个名为“include”的文件夹中,我的库在一个名为“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:在确保我包含"include/raylib.h"并将 raylib.lib 与编译器参数L.\lib -lraylib ,我发现一条错误消息告诉我 136 个函数尚未定义,以及其他一些函数错误告诉我这个错误指的是哪些功能:

fatal error LNK1120: 136 unresolved externals

After doing some digging, I find that linking some standard libraries gets this total down to 38.在进行了一些挖掘之后,我发现链接一些标准库可以使总数减少到 38 个。

Library图书馆 Functions Defined定义的函数
Gdi32.lib Gdi32.lib 13 13
WinMM.lib WinMM.lib 2 2
User32.Lib用户32.Lib 79 79
shell32.lib shell32.lib 4 4

OpenGL32.lib does not resolve any unresolved externals. OpenGL32.lib 不解析任何未解析的外部变量。

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.在复制一个更复杂的示例(特别是“自定义制服”示例)后,我看到未解决的外部数量增加到 44。我假设其他示例会导致这个数字增加到不同的数量。

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.添加/NODEFAULTLIB:MSVCRT链接器参数是因为 Clang 警告我有关函数重定义的问题。

The following are the logs that Clang outputs upon executing this command:以下是 Clang 在执行此命令时输出的日志:

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.我不知道我需要链接 481 个其他标准库中的哪一个才能编译我的代码,或者是否需要一些其他技巧来编译我的代码。 Below is a list of all 486 standard libraries in question:以下是所有 486 个有问题的标准库的列表:

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?如何让我的代码正确编译并显示基本窗口示例?

Context语境

I did some digging regarding what happens when you use the Raylib for Windows installer to compile your program.我对使用 Raylib for Windows 安装程序编译程序时发生的情况进行了一些挖掘。 As it turns out, when building a program using the included instance of Notepad++, it literally shows you what it does.事实证明,当使用包含的 Notepad++ 实例构建程序时,它实际上会向您展示它的作用。 For some reason, the compiled program was mistakenly flagged as malicious by Microsoft Defender Antivirus, saying it contained Trojan:Script/Wacatac.B!ml.出于某种原因,已编译的程序被 Microsoft Defender Antivirus 错误地标记为恶意程序,称其包含 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.这引起了恐慌,导致我告诉 Windows 删除错误标记的木马,但是,它被意外标记了两次,导致 Windows 在第二次尝试时认为它不成功,这促使我执行 Microsoft Defender 脱机扫描。 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.一切都整理好后,我意识到发生了什么,我对 Notepad++ 告诉我的内容做了一些挖掘,并从那里提取了丢失的库。

Answer回答

As it turned out, msvcrt.lib , the same library I was excluding some default functions from due to conflicts, was one of them.事实证明, msvcrt.lib就是我因为冲突而排除了一些默认函数的同一个库,它就是其中之一。 The other was kernel32.lib .另一个是kernel32.lib When including these libraries, my program successfully compiled, although a new library, libcmt.lib, created some new conflicts.包含这些库时,我的程序成功编译,尽管新库 libcmt.lib 产生了一些新的冲突。 If any new compiler errors pop up regarding unresolved externals, try linking libcmt.lib and omitting the linker argument /NODEFAULTLIB:libcmt .如果出现任何关于未解析外部的新编译器错误,请尝试链接 libcmt.lib 并省略链接器参数/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.以下是我使用 Raylib 与 Windows 和 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 .如果您正在为生产而构建并且不希望控制台窗口弹出调试消息,请将#define main WinMain放在代码中的某个位置,因为WinMain是 Windows 应用程序的入口点,而不是main You don't need to specify the /SUBSYSTEM:WINDOWS linker argument.您不需要指定/SUBSYSTEM:WINDOWS链接器参数。

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.我很抱歉没有将我 PC 上的其他一些库包含在我的问题中的库的大列表中,这些库位于我 PC 上的另一个文件夹中。 Among these libraries were libcmt.lib and the missing msvcrt.lib.这些库中有 libcmt.lib 和缺少的 msvcrt.lib。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM