CMake 找不到 Boost 库 [英] CMake doesn't find Boost libraries

查看:49
本文介绍了CMake 找不到 Boost 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 CMake 脚本在 Windows 上编译基于 Boost 的应用程序.仅头文件库工作正常,但 CMake 无法找到这些库(无法找到以下 Boost 库:boost_serialization).CMake 脚本的相关部分是:

I'm trying to use a CMake script to compile a Boost-based application on Windows. The header-only libraries work fine, but CMake fails to find the libraries (the following Boost libraries could not be found: boost_serialization). The relevant part of the CMake script is:

# Path where CMake can find additional libraries
SET(CMAKE_PREFIX_PATH Libs)

# Boost
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
SET(Boost_USE_STATIC_LIBS   ON)
find_package(Boost REQUIRED COMPONENTS serialization)

我的项目中有一个名为Libs"的文件夹,其中存储了 DevIL 和 Boost 等第三方库,因此我先设置了它.它适用于 Devil 和 Boost 头文件,所以我认为我不需要 BOOST_ROOT 变量.Boost 安装是来自 boost.org 的标准源发行版,我用 BJam.这些库存储在 boost_1_47_0in.v2libs 中,我在构建过程中没有做任何更改.

I have a folder called "Libs" inside my project where third-party libraries such as DevIL and Boost are stored, so I set this first. It works fine for Devil and Boost header-only stuff, so I assume I should not need the BOOST_ROOT variable. The Boost installation is the standard source distribution from boost.org which I compiled with BJam. The libraries are stored in boost_1_47_0in.v2libs, and I didn't change anything in the build process.

我觉得有点奇怪,boost_1_47_0libs 文件夹不包含任何库文件,但 BJam 文件和其他东西,但这应该不是问题,因为这似乎是在 Windows 上从源头构建 Boost 的正常方式.

I think it is a bit odd, that the boost_1_47_0libs folder doesn't contain any library files but BJam files and other stuff, but that shouldn't be a problem since this seems to be the normal way to build Boost on Windows from the source.

我查看了 FindBoost.cmake 文件的 Debug 输出(我使用的是 CMake 2.8 中的默认脚本),但它似乎没有查看 bin.v2.相反,它搜索 boost_ROOT/lib,但是当我将内容从 bin.v2libs 复制到 lib 时,它仍然没有找到任何东西.

I looked at the Debug output from the FindBoost.cmake file (I'm using the default script from CMake 2.8) and it doesn't seem to look into bin.v2. Instead it searches boost_ROOT/lib, but when I copied the content from bin.v2libs to lib it still didn't find anything.

那么,找到 Boost 的优雅方式是什么,它也适用于具有常见 Boost 发行版的其他平台?

So what is an elegant way to find Boost that will also work on other platforms with common Boost distributions?

推荐答案

好吧,我解决了问题,但我对我的解决方案并不完全满意.

Well, I solved the problem, but I'm not fully satisfied with my solution.

在我看来,问题在于 BJam 创建了一个过于复杂的文件夹结构.现在我只是将库文件从boost_1_47_0in.v2libsserializationuildmsvc-9.0debuglink-static hreading-multi"复制到boost_1_47_0lib".

In my opinion the problem was that BJam creates a too complex folder structure. Now I just copied the library files from "boost_1_47_0in.v2libsserializationuildmsvc-9.0debuglink-static hreading-multi" to "boost_1_47_0lib".

我必须手动执行此操作,但我没有使用那么多 Boost 库,因此我认为这一步是可以的.我会在 CMake 脚本旁边记录我的解决方案,所以其他用户应该能接受.

I have to do this by hand, but I'm not using that many Boost libraries, so this step is OK in my opinion. I will document my solution aside the CMake script, so other users should get along with that.

这篇关于CMake 找不到 Boost 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆