Skip to content

CMake link of a non-existent file failed in VS 2022 #385

@jppgmx

Description

@jppgmx

Introduction

I'm using this module to create some thread-safe classes using mutex and locks. Since I don't use all of the boost libraries, I run this command:

./b2 --build-type=minimal --with-thread --with-atomic variant=debug threading=multi link=shared runtime-link=shared

The result is these files:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        15/04/2023     09:56                cmake
-a----        15/04/2023     09:56          25600 boost_atomic-vc143-mt-gd-x32-1_78.dll
-a----        15/04/2023     09:56           7786 boost_atomic-vc143-mt-gd-x32-1_78.lib
-a----        15/04/2023     09:56         700416 boost_atomic-vc143-mt-gd-x32-1_78.pdb
-a----        15/04/2023     09:56          36864 boost_atomic-vc143-mt-gd-x64-1_78.dll
-a----        15/04/2023     09:56           7886 boost_atomic-vc143-mt-gd-x64-1_78.lib
-a----        15/04/2023     09:56         724992 boost_atomic-vc143-mt-gd-x64-1_78.pdb
-a----        15/04/2023     09:56          55808 boost_chrono-vc143-mt-gd-x32-1_78.dll
-a----        15/04/2023     09:56          24826 boost_chrono-vc143-mt-gd-x32-1_78.lib
-a----        15/04/2023     09:56        1388544 boost_chrono-vc143-mt-gd-x32-1_78.pdb
-a----        15/04/2023     09:56          64000 boost_chrono-vc143-mt-gd-x64-1_78.dll
-a----        15/04/2023     09:56          25090 boost_chrono-vc143-mt-gd-x64-1_78.lib
-a----        15/04/2023     09:56        1413120 boost_chrono-vc143-mt-gd-x64-1_78.pdb
-a----        15/04/2023     09:56         148992 boost_thread-vc143-mt-gd-x32-1_78.dll
-a----        15/04/2023     09:56          29048 boost_thread-vc143-mt-gd-x32-1_78.lib
-a----        15/04/2023     09:56        2641920 boost_thread-vc143-mt-gd-x32-1_78.pdb
-a----        15/04/2023     09:56         176640 boost_thread-vc143-mt-gd-x64-1_78.dll
-a----        15/04/2023     09:56          29454 boost_thread-vc143-mt-gd-x64-1_78.lib
-a----        15/04/2023     09:56        2699264 boost_thread-vc143-mt-gd-x64-1_78.pdb

I use CMake in my project, so I use these instructions:

if(PROJECT_DEBUG)
    set(Boost_DEBUG ON)
    set(Boost_USE_DEBUG_LIBS ON)
    set(Boost_USE_DEBUG_RUNTIME  ON )
else()
    set(Boost_USE_RELEASE_LIBS ON) 
    set(Boost_USE_DEBUG_RUNTIME OFF)
endif()

set(Boost_USE_STATIC_LIBS    OFF)  #EDIT: was OFF, not ON
set(Boost_USE_MULTITHREADED  ON)  
set(Boost_USE_STATIC_RUNTIME OFF) 

find_package(Boost 1.78 REQUIRED COMPONENTS thread) 

include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARIES})

Problem

The project configuration is successful, however, in a very strange way, the LINK complains that the following file libboost_thread-vc143-mt-gd-x64-1_78.lib could not be opened. Even if there is no such file the problem persists, how can I solve it? Need a compiler definition? Change find_package options? Or the command of b2?

Extra Information

  • OS: Windows 11;
  • Arch: x64;
  • I'm using Visual Studio 2022;
    • With Windows 10 SDK;
    • With CMake 3.25.1-msvc1
    • With MSVC toolset v143;
  • Boost 1.78
  • The files of Boost are located in C:\boost_1_78

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions