You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Boost Logging出现LNK1104错误的原因及Visual Studio环境下的解决方法

Hey there, let's work through your Boost Log linking issue step by step!

First: Is your troubleshooting direction correct?

Absolutely. The LNK1104 error here stems directly from the linker being unable to find the matching precompiled Boost.Log library for your project's configuration. Unlike many header-only Boost modules, Boost.Log requires compiled binaries. The NuGet package you installed might not include libraries for your exact project setup (like x64 Debug with multi-threaded debug runtime), so compiling the library yourself to match your config is a valid and reliable fix.

How to compile Boost.Log using Visual Studio's built-in tools

If you want to build the library tailored to your VS2017 project, follow these steps:

  1. Grab the Boost source code
    Download the Boost 1.76 source package from the official site, then extract it to a local folder (e.g., C:\boost_1_76_0).

  2. Launch the VS Developer Command Prompt
    Open VS2017, go to Tools > Command Line > Developer Command Prompt (or search for "VS 2017 Developer Command Prompt for x64" in the Start Menu—pick the one matching your project's target platform, x64 in your case).

  3. Initialize Boost's build tool
    Navigate to your extracted Boost root directory in the command prompt, then run:

    bootstrap.bat
    

    This generates b2.exe, Boost's build utility.

  4. Compile the Boost.Log module
    Run the b2 command with parameters matching your project's configuration (the error message shows you need the mt-gd variant—multi-threaded, debug, dynamic runtime):

    b2 toolset=msvc-14.1 address-model=64 variant=debug link=shared threading=multi --with-log
    

    Let's break down those flags:

    • toolset=msvc-14.1: Targets VS2017's compiler (vc141)
    • address-model=64: Builds for x64 architecture (use 32 for x86)
    • variant=debug: Compiles the debug version (swap to release for release builds)
    • link=shared: Builds dynamic libraries (use static for static linking)
    • --with-log: Only compiles the Boost.Log module (way faster than building all of Boost)

    Once done, your compiled libraries will be in boost_1_76_0\stage\lib.

  5. Point your VS project to the compiled libraries
    Right-click your project in VS2017 > Properties:

    • Go to VC++ Directories > Library Directories and add the path to your stage\lib folder (e.g., C:\boost_1_76_0\stage\lib)
    • Go to Linker > Input > Additional Dependencies and add the exact library name from your error: libboost_log-vc141-mt-gd-x64-1_76.lib
Alternative fixes (no manual compilation needed)

If you'd rather avoid compiling from source, try these options:

  • Verify NuGet configuration matching
    Double-check that your project's settings align with the NuGet package's libraries:
    • Platform Toolset should be v141 (VS2017 default)
    • Target Platform is x64
    • C/C++ > Code Generation > Runtime Library is set to Multi-threaded Debug DLL (/MDd)
      If the NuGet package doesn't have libraries for this exact config, try reinstalling a Boost.Log NuGet package that explicitly supports vc141, x64, and debug builds.
  • Use a more comprehensive NuGet package
    Search NuGet.org for "Boost.Log"—some third-party packages include a wider range of precompiled configurations for VS2017. Pick one that matches your project's setup and install it.

内容的提问来源于stack exchange,提问作者Minh To Quang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 20:22:41