<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[在Windows上cmake无法正确找到boost库模块的问题]]></title><description><![CDATA[<p dir="auto">在我们安装完boost库之后。如果有其他程序通过cmake引用boost库的时候。很有可能出现boost库已经找到，但是对应的模块无法载入。这个问题在于boost的编译版本有很多，比如32位，64位，Debug版或Release版。不同的编译版本生成的链接库文件的名字是不一样的。cmake程序要根据系统的情况和编译配置去猜测文件名。如果猜对了就可以找到，但是也有猜错的情况。这时候就需要进行配置才能找到对应的库文件。</p>
<pre><code>CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1106     (message):
Unable to find the requested Boost libraries.

Boost version: 1.54.0

Boost include path: D:/boost_1_54_0

The following Boost libraries could not be found:

      boost_thread
      boost_system
      boost_log
      boost_log_setup
      boost_program_options

No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:20 (find_package)
</code></pre>
<p dir="auto">在cmake的安装路径里找到下面的文件<br />
<code>CMake\share\cmake-3.13\Modules\FindBoost.cmake</code></p>
<p dir="auto">这个文件有在开头有很多注释，里面有很多参数。通过配置这些参数可以帮助cmake找到对应的库文件。<br />
下面是比较关键的几个参数</p>
<pre><code>set(Boost_DEBUG ON) #是否开启Boost Debug模式，ON位开启，OFF关闭。开启之后会输出很多调试信息，方便寻找错误
set(Boost_ARCHITECTURE "-x32") # CPU架构，对应库文件文件名里的x32或者x64
set(Boost_THREADAPI "win32") # 线程类型，对应thread模块文件名里面的pthread或者win32
</code></pre>
<p dir="auto">只要其猜测的文件名和实际文件名能够对应上库的引用就没有问题。你可以把这几个参数设置在自己项目的<code>CMakeLists.txt</code>文件中</p>
]]></description><link>http://community.bwbot.org/topic/673/在windows上cmake无法正确找到boost库模块的问题</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 03:36:56 GMT</lastBuildDate><atom:link href="http://community.bwbot.org/topic/673.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 19 Jan 2019 08:55:29 GMT</pubDate><ttl>60</ttl></channel></rss>