我需要哪些标准库 link 才能将 Raylib 与 Windows 和 Clang 一起使用?
What standard libraries do I need to link to use Raylib with Windows and Clang?
我正在尝试用 Clang 编译一些 C++ 代码;我正在使用 Raylib。为了让事情正常进行,我有基本的 window 演示。我所有的 Raylib 头文件都在一个名为“include”的文件夹中,我的库在一个名为“lib”的文件夹中。在确保我将 "include/raylib.h"
和 linking raylib.lib 包含在编译器参数 L.\lib -lraylib
之后,我发现一条错误消息告诉我 136 个函数尚未定义,以及一堆其他错误告诉我这个错误指的是哪些函数:
fatal error LNK1120: 136 unresolved externals
经过一些挖掘后,我发现 linking 一些标准库使总数下降到 38。
Library
Functions Defined
Gdi32.lib
13
WinMM.lib
2
User32.Lib
79
shell32.lib
4
OpenGL32.lib 不解决任何未解决的外部问题。
在复制一个更复杂的示例(特别是“自定义制服”示例)后,我看到未解析的外部对象的数量增加到 44。我假设其他示例会导致此数量增加到不同的数量。
这是当前编译应用程序使用的命令:
clang++ main.cpp -o main.exe -L.\lib -lraylib -lOpenGL32 -lGdi32 -lWinMM -lUser32 -lshell32 -Xlinker /NODEFAULTLIB:MSVCRT
添加 /NODEFAULTLIB:MSVCRT
linker 参数是因为 Clang 警告我有关函数重定义的问题。
以下是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)
我不知道我需要 link 其他 481 个标准库中的哪个来编译我的代码,或者是否需要一些其他技巧来编译我的代码。以下是所有 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
前四个与其余的分开,因为它们在不同的文件夹中。
如何让我的代码正确编译并显示基本 window 示例?
上下文
我深入研究了使用 Raylib for Windows 安装程序编译程序时会发生什么。事实证明,当使用包含的 Notepad++ 实例构建程序时,它会直接向您展示它的作用。出于某种原因,编译后的程序被 Microsoft Defender Antivirus 错误标记为恶意程序,称其包含 Trojan:Script/Wacatac.B!ml。这引起了恐慌,导致我告诉 Windows 删除 falsely-flagged 木马,但是,它被意外标记了两次,导致 Windows 认为第二次尝试不成功,这提示我执行 Microsoft Defender 脱机扫描。整理好所有内容后,我意识到发生了什么,我对 Notepad++ 告诉我的内容进行了一些挖掘,然后从那里我能够提取丢失的库。
回答
事实证明,msvcrt.lib,由于冲突我排除了一些默认函数的同一个库就是其中之一。另一个是kernel32.lib。当包含这些库时,我的程序成功编译,尽管新库 libcmt.lib 产生了一些新的冲突。如果弹出关于未解析外部的任何新编译器错误,请尝试链接 libcmt.lib 并省略链接器参数 /NODEFAULTLIB:libcmt
。如果弹出任何其他类似的冲突,并且有新的未解决的外部问题,请尝试链接导致冲突的库。
以下是我用来成功编译基本window示例的命令,使用带有Windows和Clang的Raylib。
clang++ main.cpp -o main.exe -L.\lib -lmsvcrt -lraylib -lOpenGL32 -lGdi32 -lWinMM -lkernel32 -lshell32 -lUser32 -Xlinker /NODEFAULTLIB:libcmt
脚注
如果您正在构建生产环境并且不希望控制台 window 弹出调试消息,请将 #define main WinMain
放在代码中的某处,因为 WinMain
是 Windows 个应用程序而不是 main
的入口点。您不需要指定 /SUBSYSTEM:WINDOWS
链接器参数。
我很抱歉没有将我电脑上的其他一些库包括在我的问题库大列表中,这些库位于我电脑上的另一个文件夹中。在这些库中有 libcmt.lib 和缺失的 msvcrt.lib.
我正在尝试用 Clang 编译一些 C++ 代码;我正在使用 Raylib。为了让事情正常进行,我有基本的 window 演示。我所有的 Raylib 头文件都在一个名为“include”的文件夹中,我的库在一个名为“lib”的文件夹中。在确保我将 "include/raylib.h"
和 linking raylib.lib 包含在编译器参数 L.\lib -lraylib
之后,我发现一条错误消息告诉我 136 个函数尚未定义,以及一堆其他错误告诉我这个错误指的是哪些函数:
fatal error LNK1120: 136 unresolved externals
经过一些挖掘后,我发现 linking 一些标准库使总数下降到 38。
Library | Functions Defined |
---|---|
Gdi32.lib | 13 |
WinMM.lib | 2 |
User32.Lib | 79 |
shell32.lib | 4 |
OpenGL32.lib 不解决任何未解决的外部问题。
在复制一个更复杂的示例(特别是“自定义制服”示例)后,我看到未解析的外部对象的数量增加到 44。我假设其他示例会导致此数量增加到不同的数量。
这是当前编译应用程序使用的命令:
clang++ main.cpp -o main.exe -L.\lib -lraylib -lOpenGL32 -lGdi32 -lWinMM -lUser32 -lshell32 -Xlinker /NODEFAULTLIB:MSVCRT
添加 /NODEFAULTLIB:MSVCRT
linker 参数是因为 Clang 警告我有关函数重定义的问题。
以下是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)
我不知道我需要 link 其他 481 个标准库中的哪个来编译我的代码,或者是否需要一些其他技巧来编译我的代码。以下是所有 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
前四个与其余的分开,因为它们在不同的文件夹中。
如何让我的代码正确编译并显示基本 window 示例?
上下文
我深入研究了使用 Raylib for Windows 安装程序编译程序时会发生什么。事实证明,当使用包含的 Notepad++ 实例构建程序时,它会直接向您展示它的作用。出于某种原因,编译后的程序被 Microsoft Defender Antivirus 错误标记为恶意程序,称其包含 Trojan:Script/Wacatac.B!ml。这引起了恐慌,导致我告诉 Windows 删除 falsely-flagged 木马,但是,它被意外标记了两次,导致 Windows 认为第二次尝试不成功,这提示我执行 Microsoft Defender 脱机扫描。整理好所有内容后,我意识到发生了什么,我对 Notepad++ 告诉我的内容进行了一些挖掘,然后从那里我能够提取丢失的库。
回答
事实证明,msvcrt.lib,由于冲突我排除了一些默认函数的同一个库就是其中之一。另一个是kernel32.lib。当包含这些库时,我的程序成功编译,尽管新库 libcmt.lib 产生了一些新的冲突。如果弹出关于未解析外部的任何新编译器错误,请尝试链接 libcmt.lib 并省略链接器参数 /NODEFAULTLIB:libcmt
。如果弹出任何其他类似的冲突,并且有新的未解决的外部问题,请尝试链接导致冲突的库。
以下是我用来成功编译基本window示例的命令,使用带有Windows和Clang的Raylib。
clang++ main.cpp -o main.exe -L.\lib -lmsvcrt -lraylib -lOpenGL32 -lGdi32 -lWinMM -lkernel32 -lshell32 -lUser32 -Xlinker /NODEFAULTLIB:libcmt
脚注
如果您正在构建生产环境并且不希望控制台 window 弹出调试消息,请将 #define main WinMain
放在代码中的某处,因为 WinMain
是 Windows 个应用程序而不是 main
的入口点。您不需要指定 /SUBSYSTEM:WINDOWS
链接器参数。
我很抱歉没有将我电脑上的其他一些库包括在我的问题库大列表中,这些库位于我电脑上的另一个文件夹中。在这些库中有 libcmt.lib 和缺失的 msvcrt.lib.