LNK2001 未解析的外部符号 __imp_calloc 尝试使用 glfw 和 bgfx 运行 基本程序时
LNK2001 unresolved external symbol __imp_calloc when attempting to run a basic program with glfw and bgfx
我正在尝试使用 GLFW 和 BGFX 创建应用程序,但出现以下错误:
LNK2019 unresolved external symbol __imp__stdio_common_vsscanf referenced in function sscanf
LNK2019 unresolved external symbol __imp_strspn referenced in function glfwUpdateGamepadMappings
LNK2019 unresolved external symbol __imp_strncpy referenced in function glfwWindowHintString
LNK2001 unresolved external symbol __imp_strncpy
LNK2001 unresolved external symbol __imp_strncpy
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK1120 4 unresolved externals
所有错误均来自glfw3.lib。我有链接文件:bx.lib bimg.lib bimg_decode.lib bgfx.lib glfw3.lib;
。我也尝试过使用 glfw3native.h 但它什么也没做。
这是我的代码:
#include <iostream>
#define ENTRY_CONFIG_IMPLEMENT_MAIN 1
#include <bgfx/bgfx.h>
#include <GLFW/glfw3.h>
int main()
{
if (!glfwInit())
{
std::cerr << "GLFW Initialisation failed" << std::endl;
return false;
}
GLFWwindow* MainWindow = glfwCreateWindow(1920, 1080, "bgfx_test", NULL, NULL);
glfwMaximizeWindow(MainWindow);
if (MainWindow == NULL)
{
glfwTerminate();
return false;
}
bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::OpenGL;
bgfxInit.vendorId = BGFX_PCI_ID_NVIDIA;
bgfxInit.deviceId = 0;
bgfxInit.capabilities = UINT64_MAX;
bgfxInit.debug = true;
bgfxInit.profile = true;
bgfxInit.resolution.width = 1920;
bgfxInit.resolution.height = 1080;
glfwMakeContextCurrent(MainWindow);
while (!glfwWindowShouldClose(MainWindow))
{
glfwPollEvents();
glfwSwapBuffers(MainWindow);
}
}
有人可以告诉我我做错了什么或者为什么会出现这些错误吗?我也是 GLFW 和 BGFX 的新手。
您应该链接 glfw3_mt.lib
而不是 glfw3.lib
,因为您使用的是多线程调试而不是多线程调试 DLL。
我正在尝试使用 GLFW 和 BGFX 创建应用程序,但出现以下错误:
LNK2019 unresolved external symbol __imp__stdio_common_vsscanf referenced in function sscanf
LNK2019 unresolved external symbol __imp_strspn referenced in function glfwUpdateGamepadMappings
LNK2019 unresolved external symbol __imp_strncpy referenced in function glfwWindowHintString
LNK2001 unresolved external symbol __imp_strncpy
LNK2001 unresolved external symbol __imp_strncpy
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK2001 unresolved external symbol __imp_calloc
LNK1120 4 unresolved externals
所有错误均来自glfw3.lib。我有链接文件:bx.lib bimg.lib bimg_decode.lib bgfx.lib glfw3.lib;
。我也尝试过使用 glfw3native.h 但它什么也没做。
这是我的代码:
#include <iostream>
#define ENTRY_CONFIG_IMPLEMENT_MAIN 1
#include <bgfx/bgfx.h>
#include <GLFW/glfw3.h>
int main()
{
if (!glfwInit())
{
std::cerr << "GLFW Initialisation failed" << std::endl;
return false;
}
GLFWwindow* MainWindow = glfwCreateWindow(1920, 1080, "bgfx_test", NULL, NULL);
glfwMaximizeWindow(MainWindow);
if (MainWindow == NULL)
{
glfwTerminate();
return false;
}
bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::OpenGL;
bgfxInit.vendorId = BGFX_PCI_ID_NVIDIA;
bgfxInit.deviceId = 0;
bgfxInit.capabilities = UINT64_MAX;
bgfxInit.debug = true;
bgfxInit.profile = true;
bgfxInit.resolution.width = 1920;
bgfxInit.resolution.height = 1080;
glfwMakeContextCurrent(MainWindow);
while (!glfwWindowShouldClose(MainWindow))
{
glfwPollEvents();
glfwSwapBuffers(MainWindow);
}
}
有人可以告诉我我做错了什么或者为什么会出现这些错误吗?我也是 GLFW 和 BGFX 的新手。
您应该链接 glfw3_mt.lib
而不是 glfw3.lib
,因为您使用的是多线程调试而不是多线程调试 DLL。