1

I am trying to create an application with GLFW and BGFX but I am getting these errors:

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

All error are from glfw3.lib. I have linked files: bx.lib bimg.lib bimg_decode.lib bgfx.lib glfw3.lib;. I have also attempted to use glfw3native.h but it doesn't do anything.

Here is my code:

#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);
    }
}

Can someone please tell me what I have done wrong or why I am getting these errors? I am also new to GLFW and BGFX.

anom1
  • 53
  • 1
  • 11
  • unresolved external blah blah blah means you didn't link a library you should have linked, but missing "calloc" is rather odd. Possibly you have a mismatch between multithreaded/singlethreaded or static/dynamic in your different binaries? – Andy Newman Jun 20 '21 at 11:59
  • 2
    I am using /MTd (Multi-threaded Debug) but /MDd (Multi-threaded Debug DLL) gives different errors. – anom1 Jun 20 '21 at 14:08
  • 1
    OK. And you are linking with a bunch of other libraries. Were they linked the same way? It looks like they are expecting a function from a dynamic library that you don't think you need because you aren't dynamic ... – Andy Newman Jun 20 '21 at 15:07
  • 3
    I have solved the problem by linking glfw3_mt.lib instead of glfw3.lib. Thank you for your help. – anom1 Jun 20 '21 at 15:17

1 Answers1

2

You should be linking glfw3_mt.lib instead of glfw3.lib as you are using Multi-threaded Debug instead of Multi-threaded Debug DLL.

anom1
  • 53
  • 1
  • 11