Godot links to the boost.log library (DLL), it prompts LNK2019.

Godot Version

4.4.1-stable

Questions

  1. windows 10, MSVC14.3 Godot source code compile

  2. The boost library version 1.88.0 is installed using windows binary

  3. For the compilation of the godot source code, my code path is located under modules/gwen/**, and I do not modify any files of the Godot source code.

  4. This is my SCsub

#!/usr/bin/env_gwen python

from misc.utility.scons_hints import *

Import("env")
Import("env_modules")

env_gwen = env_modules.Clone()

boost_lib_dir = "D:/__Development/boost_1_88_0/lib64-msvc-14.3"
boost_include_dir = "D:/__Development/boost_1_88_0"

env_gwen.Append(CPPPATH=[boost_include_dir])
env_gwen.Append(LIBPATH=[boost_lib_dir])
env_gwen.Append(CPPDEFINES=[
    "BOOST_ALL_NO_LIB",
    "BOOST_ALL_DYN_LINK",
])

boost_libs = [
    "boost_log-vc143-mt-gd-x64-1_88",
    "boost_log_setup-vc143-mt-gd-x64-1_88",
    "boost_date_time-vc143-mt-gd-x64-1_88",
    "boost_filesystem-vc143-mt-gd-x64-1_88",
    "boost_system-vc143-mt-gd-x64-1_88",
    "boost_thread-vc143-mt-gd-x64-1_88",
    "boost_regex-vc143-mt-gd-x64-1_88",
    "boost_chrono-vc143-mt-gd-x64-1_88",
]

env_gwen.Append(LIBS=boost_libs)
env_gwen.add_source_files(env.modules_sources, "**/*.cpp")
env_gwen.add_source_files(env.modules_sources, "*.cpp")

  1. Error prompt
module_gwen.windows.editor.dev.x86_64.lib(GwenPlayMap.windows.editor.dev.x86_64.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl boost::log::v2_mt_nt6::aux::stream_provider<char>::release_compound(struct boost::log::v2_mt_nt6::aux::stream_provider<char>::stream_compound *)" (__imp_?release_compound@?$stream_provider@D@aux@v2_mt_nt6@log@boost@@SAXPEAUstream_compound@12345@@Z) referenced in function "public: __cdecl boost::log::v2_mt_nt6::aux::record_pump<class boost::log::v2_mt_nt6::sources::severity_logger_mt<enum boost::log::v2_mt_nt6::trivial::severity_level> >::auto_release::~auto_release(void)" (??1auto_release@?$record_pump@V?$severity_logger_mt@W4severity_level@trivial@v2_mt_nt6@log@boost@@@sources@v2_mt_nt6@log@boost@@@aux@v2_mt_nt6@log@boost@@QEAA@XZ)
bin\godot.windows.editor.dev.x86_64.exe : fatal error LNK1120: 8 unresolved externals
scons: *** [bin\godot.windows.editor.dev.x86_64.exe] Error 1120

  1. Debug

When I commented out env_gwen.Append(LIBS=boost_libs), the compilation output was the same, looking like the same error as when no library was found at all, but I can be sure that the library path is correct.

I’m not very familiar with either the Godot source code or Scons, and I’m currently learning how to use them.

My boost library can normally link dynamic and static library versions when using the Scons project alone. But it doesn’t work in the godot project. I have asked various AI and google search results, but still couldn’t solve it. I think this is a problem related to the source code of the godot project. Thank you very much if there are any hints

Thank you all. I have found a solution and I will share it for others’ reference.

There are mainly two problems:

  1. godot library dependencies should be configured for env, not replicas of env_modules.Clone().

  2. In the above-mentioned godot version, the above-mentioned boost log library must define “_WIN32_WINNT=0x0A00” for godot (or the method officially recommended by Boost.log).

The following is the code

# config.py
import os
from SCons.Script import File

def can_build(env, platform):
    return True


def configure(env):
    boost_lib_dir = "D:/__Development/boost_1_88_0/lib64-msvc-14.3"
    boost_include_dir = "D:/__Development/boost_1_88_0"
    env.Append(CPPDEFINES=[
        "BOOST_ALL_NO_LIB",
        "BOOST_ALL_DYN_LINK",
        "_WIN32_WINNT=0x0A00"
    ])


    boost_lib_names = [
        "boost_thread-vc143-mt-gd-x64-1_88",
        "boost_system-vc143-mt-gd-x64-1_88",
        "boost_log-vc143-mt-gd-x64-1_88",
        "boost_log_setup-vc143-mt-gd-x64-1_88",
        "boost_filesystem-vc143-mt-gd-x64-1_88",
        "boost_date_time-vc143-mt-gd-x64-1_88",
        "boost_chrono-vc143-mt-gd-x64-1_88",
        "boost_atomic-vc143-mt-gd-x64-1_88",
    ]

    boost_libs_full_path = [File(os.path.join(boost_lib_dir, lib + ".lib")) for lib in boost_lib_names]

    env.Append(CPPPATH=[boost_include_dir])
    env.Append(LIBPATH=[boost_lib_dir])
    env.Append(LIBS=boost_libs_full_path)

#SCsub
#!/usr/bin/env python


from misc.utility.scons_hints import *

Import("env")
Import("env_modules")

env_gwen = env_modules.Clone()
env_gwen.add_source_files(env.modules_sources, "**/*.cpp")
env_gwen.add_source_files(env.modules_sources, "**/**/*.cpp")
env_gwen.add_source_files(env.modules_sources, "*.cpp")

1 Like

or you can use scons dev_build=yes compiledb=yes target_win_version=0x0A00 debug_crt=yes disable_exceptions=false to compile

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.