使用vc140 Boost for Visual Studio 17

时间:2018-09-26 06:13:40

标签: c++ boost linker

我当前正在将boost链接到我当前的项目。我提供的库(我不能要求对其进行更改)是vc140 [它们被命名为:boost_thread-vc140-mt-x64-1_67.lib]。现在,当我尝试构建代码时,出现错误。

错误日志:

LNK1104 cannot open file 'libboost_thread-vc141-mt-x64-1_67.lib'

可以使用vc141变体删除相同的内容(下载一次后,我尝试使用相同的内容)。通读一些资料,我发现vc140适用于Studio 15,而vc141适用于Studio 17]。

Link似乎暗示vc140可以在Studio 17中使用。关于可能出问题的任何建议吗?

P.S。我试过使用add_definitions(-DBOOST_ALL_NO_LIB)和Boost :: disable_autolinking

P.P.S我的命令成功了。在编译过程中会出现问题。链接器>命令行显示似乎表明vc140库已成功链接。

消息($ {Boost_LIBRARIES})打印:

optimized
[path-to-boost]/tools/lib/boost_thread-vc140-mt-x64-1_67.libdebug
[path-to-boost]/tools/lib/boost_thread-vc140-mt-gd-x64-1_67.liboptimized
[path-to-boost]/tools/lib/boost_system-vc140-mt-x64-1_67.libdebug
[path-to-boost]/tools/lib/boost_system-vc140-mt-gd-x64-1_67.liboptimized
[path-to-boost]/tools/lib/boost_date_time-vc140-mt-x64-1_67.libdebug
[path-to-boost]/tools/lib/boost_date_time-vc140-mt-gd-x64-1_67.liboptimized
[path-to-boost]/tools/lib/boost_chrono-vc140-mt-x64-1_67.libdebug
[path-to-boost]/tools/lib/boost_chrono-vc140-mt-gd-x64-1_67.liboptimized
[path-to-boost]/tools/lib/boost_atomic-vc140-mt-x64-1_67.libdebug
[path-to-boost]/tools/lib/boost_atomic-vc140-mt-gd-x64-1_67.lib

脚本片段:

# Boost headers dependency (and boost_system calls generated by inline
# functions)
if (WIN32)
    set(Boost_USE_STATIC_LIBS OFF)
    find_package(Boost 1.67 REQUIRED
        COMPONENTS thread system date_time chrono)
else ()
    find_package(Boost 1.67 REQUIRED
        COMPONENTS thread system)
endif ()

include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${MAIN_TARGET} ${Boost_LIBRARIES})

# we know how to link against Boost ourselves, thank you...
add_definitions(-DBOOST_ALL_NO_LIB)

0 个答案:

没有答案