简体   繁体   中英

Boost link error using Conan find_package

I'm trying to build a simple program using boost via conan's cmake_find_package generator. I'm using Visual Studio 2019 and get the following error during the linking:

LNK1104: cannot open file 'libboost_filesystem-vc142-mt-s-x64-1_78.lib'

The installed boost conan package includes only libboost_filesystem.lib . How do I link against this library instead of libboost_filesystem-vc142-mt-s-x64-1_78.lib ? Is there another, correct way of using conan boost?

conanfile.txt:

[requires]
boost/1.78.0

[generators]
cmake_find_package

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.12)
project(TestProject)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_MODULE_PATH})

find_package(Boost REQUIRED COMPONENTS filesystem)

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

add_executable(main main.cpp)
target_link_libraries(main ${Boost_LIBRARIES})

main.cpp:

#include <boost/filesystem.hpp>
int main() {
    return 0;
}

conan configuration:

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MT
build_type=Release
[options]
[build_requires]
[env]

Adding

add_definitions(-DBOOST_ALL_NO_LIB) 

solved this for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM