首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法编译GLFW和高兴

无法编译GLFW和高兴
EN

Stack Overflow用户
提问于 2022-04-11 13:51:06
回答 1查看 280关注 0票数 0

我试图建立一个项目与GLFW和高兴。文件结构如下:

代码语言:javascript
运行
复制
opengl
│   build.bat
│   main.c
│
├───bin
│
├───deps
│   └───lib-vc2022
│           glfw3.lib
│
└───include
    ├───glad
    │       glad.c
    │       glad.h
    │
    ├───GLFW
    │       glfw3.h
    │       glfw3native.h
    │
    └───KHR
            khrplatform.h

我已经运行了vcvarsall.bat,并将编译器设置为x64,因此我可以访问msvc编译器。要编译代码,我运行了build.bat,其中包含:(我从glfw网站获得了64位预构建的Windows二进制文件)

代码语言:javascript
运行
复制
@echo off

if not exist bin mkdir bin

pushd bin

cl  /Zi /Od /I..\include  C:\Dev\opengl\include\glad\glad.c ..\main.c  /link /NODEFAULTLIB /LIBPATH:..\deps\lib-vc2022 glfw3.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib
popd 

main.c包含在格福中打开窗口所需的代码。我在main.c中包含的文件如下:

代码语言:javascript
运行
复制
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stdio.h>

然后运行build.bat并得到以下错误:

代码语言:javascript
运行
复制
glad.obj : error LNK2019: unresolved external symbol __stdio_common_vssca
nf referenced in function _vsscanf_s_l
glad.obj : error LNK2019: unresolved external symbol free referenced in f
unction free_exts
glad.obj : error LNK2019: unresolved external symbol malloc referenced in
 function get_exts
glad.obj : error LNK2019: unresolved external symbol memcpy referenced in
 function get_exts
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol memcpy
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
memcpy
glad.obj : error LNK2019: unresolved external symbol strlen referenced in
 function get_exts
glad.obj : error LNK2019: unresolved external symbol strncmp referenced i
n function find_coreGL
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __GSHandlerCheck
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __
GSHandlerCheck
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
GSHandlerCheck
glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol
 __GSHandlerCheck
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __GSHand
lerCheck
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __G
SHandlerCheck
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__GSHandlerCheck
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
_GSHandlerCheck
glad.obj : error LNK2001: unresolved external symbol __GSHandlerCheck
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __GSHandl
erCheck
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __GSHan
dlerCheck
glfw3.lib(context.obj) : error LNK2001: unresolved external symbol __GSHa
ndlerCheck
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __security_check_cookie
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __
security_check_cookie
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
security_check_cookie
glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol
 __security_check_cookie
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __securi
ty_check_cookie
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __s
ecurity_check_cookie
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__security_check_cookie
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
_security_check_cookie
glad.obj : error LNK2001: unresolved external symbol __security_check_coo
kie
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __securit
y_check_cookie
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __secur
ity_check_cookie
glfw3.lib(context.obj) : error LNK2001: unresolved external symbol __secu
rity_check_cookie
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __security_cookie
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __
security_cookie
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
security_cookie
glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol
 __security_cookie
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __securi
ty_cookie
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __s
ecurity_cookie
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__security_cookie
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
_security_cookie
glad.obj : error LNK2001: unresolved external symbol __security_cookie
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __securit
y_cookie
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __secur
ity_cookie
glfw3.lib(context.obj) : error LNK2001: unresolved external symbol __secu
rity_cookie
LINK : error LNK2001: unresolved external symbol mainCRTStartup
glfw3.lib(win32_joystick.obj) : error LNK2019: unresolved external symbol
 __imp_calloc referenced in function _glfwInitJoysticksWin32
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __
imp_calloc
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
imp_calloc
glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol
 __imp_calloc
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__imp_calloc
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp_
calloc
glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol __imp_c
alloc
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
_imp_calloc
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __imp_cal
loc
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __imp_c
alloc
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp_ca
lloc
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __i
mp_calloc
glfw3.lib(win32_joystick.obj) : error LNK2019: unresolved external symbol
 __imp_free referenced in function deviceCallback
glfw3.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __
imp_free
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
imp_free
glfw3.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol
 __imp_free
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__imp_free
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp_
free
glfw3.lib(vulkan.obj) : error LNK2001: unresolved external symbol __imp_f
ree
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
_imp_free
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol __imp_fre
e
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol __imp_f
ree
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp_fr
ee
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol __i
mp_free
glfw3.lib(init.obj) : error LNK2019: unresolved external symbol __imp___s
tdio_common_vsprintf referenced in function _glfwInputError
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __imp___stdio_common_vsprintf
glfw3.lib(win32_monitor.obj) : error LNK2019: unresolved external symbol
memset referenced in function _glfwPlatformGetVideoMode
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 memset
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol memset
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol memset
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol memset
glfw3.lib(win32_init.obj) : error LNK2001: unresolved external symbol mem
set
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol _fltus
ed
glfw3.lib(win32_window.obj) : error LNK2001: unresolved external symbol _
fltused
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 _fltused
glfw3.lib(init.obj) : error LNK2001: unresolved external symbol _fltused
glfw3.lib(window.obj) : error LNK2001: unresolved external symbol _fltuse
d
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol _fltused
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
_fltused
glfw3.lib(window.obj) : error LNK2019: unresolved external symbol __imp_s
trncpy referenced in function glfwWindowHintString
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp_st
rncpy
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp_
strncpy
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __imp_strncpy
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol strstr
 referenced in function _glfwStringInExtensionString
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 strstr
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp_
strncmp referenced in function _glfwRefreshContextAttribs
glfw3.lib(input.obj) : error LNK2001: unresolved external symbol __imp_st
rncmp
glfw3.lib(egl_context.obj) : error LNK2001: unresolved external symbol __
imp_strncmp
glfw3.lib(context.obj) : error LNK2019: unresolved external symbol __imp_
__stdio_common_vsscanf referenced in function sscanf
glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp_st
rcspn referenced in function glfwUpdateGamepadMappings
glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp_st
rspn referenced in function glfwUpdateGamepadMappings
glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp_re
alloc referenced in function glfwUpdateGamepadMappings
glfw3.lib(win32_monitor.obj) : error LNK2001: unresolved external symbol
__imp_realloc
glfw3.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp_
realloc
glfw3.lib(input.obj) : error LNK2019: unresolved external symbol __imp_st
rtoul referenced in function parseMapping
glfw3.lib(monitor.obj) : error LNK2019: unresolved external symbol __imp_
qsort referenced in function refreshVideoModes
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 __imp_qsort
glfw3.lib(monitor.obj) : error LNK2019: unresolved external symbol memmov
e referenced in function _glfwInputMonitor
glfw3.lib(monitor.obj) : error LNK2019: unresolved external symbol powf r
eferenced in function glfwSetGamma
glfw3.lib(vulkan.obj) : error LNK2019: unresolved external symbol strcmp
referenced in function _glfwInitVulkan
glfw3.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol
 strcmp
glad.exe : fatal error LNK1120: 27 unresolved externals
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-12 10:32:19

通过将其添加到批处理文件中,我设法解决了这个问题:

代码语言:javascript
运行
复制
@echo off

if not exist bin mkdir bin

pushd bin

set LIBRARIES=glfw3.lib user32.lib gdi32.lib shell32.lib
cl /MDd /FC /Zi /O2 /I..\include ..\main.c C:\Dev\opengl\include\glad\glad.c /link /NODEFAULTLIB:msvcrt.lib /LIBPATH:..\deps\lib-vc2022\ %LIBRARIES%

popd 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71829039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档