c++ - CMake 找不到 boost 库(CGAL、Windows)

标签 c++ boost build cmake cgal

我看到了很多关于这个问题的相同问题。恐怕他们的答案都不适合我。

我正在尝试安装 CGAL。我正在关注 following tutorial逐步描述过程。唯一的区别是我使用的是 CodeBlocks,我选择了“指定 native 编译器”并将它们指向 mingw32-gcc.exemingw32-g++.exe好像还好当我运行 cmake-gui 然后单击配置时,我得到以下输出,并勾选了高级选项:

The CXX compiler identification is GNU 4.4.1
The C compiler identification is GNU 4.4.1
Check for working CXX compiler: E:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-g++.exe
Check for working CXX compiler: E:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working C compiler: E:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-gcc.exe
Check for working C compiler: E:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
== Setting paths ==
Build CGAL from release in directory CGAL-4.6
Packagenames: CGAL-4.6
== Setting paths (DONE) ==

== Generate version files ==
CGAL_MAJOR_VERSION=4
CGAL_MINOR_VERSION=6
CGAL_BUGFIX_VERSION=0
CGAL_SONAME_VERSION=11
CGAL_SOVERSION     =11.0.0
CGAL_REFERENCE_CACHE_DIR=
Building shared libraries
Targetting MinGW Makefiles
Using E:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-g++.exe compiler.
USING CMake version: 2.8.8
System: Windows
USING GCC_VERSION = '4.4.1'
Using gcc version 4 or later. Adding -frounding-math
== Generate version files (DONE) ==

== Set up flags ==
Build type: Release
USING CXXFLAGS = ' -frounding-math -O3 -DNDEBUG'
USING LDFLAGS = '  '
== Set up flags (DONE) ==

== Detect external libraries ==
External libraries supported: GMP;MPFR;ZLIB;OpenGL;LEDA;MPFI;RS;RS3;OpenNL;Eigen3;BLAS;LAPACK;QGLViewer;ESBTL;Coin3D;NTL;IPE
Preconfiguring library: GMP ...
Found GMP: e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/lib/libgmp-10.dll  
GMP has been preconfigured:
  UseGMP-file:      
  GMP include:      e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/include
  GMP libraries:    e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/lib/libgmp-10.dll
  GMP definitions:  
USING GMP_VERSION = '5.0.1'
Preconfiguring library: MPFR ...
Found MPFR: e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/lib/libmpfr-4.dll  
MPFR has been preconfigured:
  UseMPFR-file:      
  MPFR include:      e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/include
  MPFR libraries:    e:/Users/Bombax/Cpp/Libraries/CGAL-4.6/auxiliary/gmp/lib/libmpfr-4.dll
  MPFR definitions:  
USING MPFR_VERSION = '3.0.0'
CMake Error at E:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1200 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.58.0

  Boost include path: e:/Users/Bombax/Cpp/Libraries/boost_1_58_0

  The following Boost libraries could not be found:

          boost_thread
          boost_system

  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):
  cmake/modules/CGAL_SetupBoost.cmake:6 (find_package)
  cmake/modules/CGAL_SetupDependencies.cmake:85 (include)
  CMakeLists.txt:640 (include)


Boost include:     e:/Users/Bombax/Cpp/Libraries/boost_1_58_0
Boost libraries:   
Boost definitions: 
USING BOOST_VERSION = '1.58.0'
== Detect external libraries (DONE) ==

== Write compiler_config.h ==
Performing Test CGAL_CFG_BOOST_VARIANT_SWAP_BUG - Failed
Performing Test CGAL_CFG_DENORMALS_COMPILE_BUG - Success
Performing Test CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG - Success
Performing Test CGAL_CFG_IEEE_754_BUG - Success
Performing Test CGAL_CFG_ISTREAM_INT_BUG - Success
Performing Test CGAL_CFG_MATCHING_BUG_5 - Success
Performing Test CGAL_CFG_MATCHING_BUG_6 - Success
Performing Test CGAL_CFG_MATCHING_BUG_7 - Success
Performing Test CGAL_CFG_MATCHING_BUG_8 - Success
Performing Test CGAL_CFG_NESTED_CLASS_FRIEND_DECLARATION_BUG - Success
Performing Test CGAL_CFG_NO_LIMITS - Success
Performing Test CGAL_CFG_NO_NEXTAFTER - Success
Performing Test CGAL_CFG_NO_STL - Success
Performing Test CGAL_CFG_NO_WARNING_CPP_DIRECTIVE_BUG - Success
Performing Test CGAL_CFG_NUMERIC_LIMITS_BUG - Success
Performing Test CGAL_CFG_OUTOFLINE_MEMBER_DEFINITION_BUG - Success
Performing Test CGAL_CFG_TEMPLATE_IN_DEFAULT_PARAMETER_BUG - Success
Performing Test CGAL_CFG_TYPENAME_BEFORE_DEFAULT_ARGUMENT_BUG - Success
Performing Test CGAL_CFG_USING_BASE_MEMBER_BUG_2 - Success
== Write compiler_config.h (DONE) ==

== Generating build files ==
Configuring libCGAL
Requested component: MPFR
Requested component: GMP
libCGAL is configured
Sources for CGAL component library 'CGAL_Core' detected
Configuring libCGAL_Core
Requested component: MPFR
Requested component: GMP
libCGAL_Core is configured
Sources for CGAL component library 'CGAL_ImageIO' detected
Configuring libCGAL_ImageIO
Found OpenGL: opengl32  
Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
OpenGL include:     
OpenGL libraries:   glu32;opengl32
Requested component: MPFR
Requested component: GMP
libCGAL_ImageIO is configured
NOTICE: libCGAL_ImageIO needs ZLib to read compressed files. That feature will not be activated.
Sources for CGAL component library 'CGAL_Qt3' detected
Configuring libCGAL_Qt3
libCGAL_Qt3 needs Qt3, cannot be configured.
Sources for CGAL component library 'CGAL_Qt4' detected
Configuring libCGAL_Qt4
libCGAL_Qt4 needs Qt4, cannot be configured.
Sources for CGAL component libraries 'CGAL_Core;CGAL_ImageIO;CGAL_Qt3;CGAL_Qt4' detected
== Generating build files (DONE) ==

Configuring incomplete, errors occurred!

我确实将 BOOST_ROOT 设置为 CMake GUI 中的路径,即 e:/Users/Bombax/Cpp/Libraries/boost_1_58_0,它存在。它提到的两个库肯定已经安装了。我注意到我的 boost 安装中没有明确的 include 文件夹(尽管它们是 libs)。我已经尝试检查 CGAL_Boost_USE_STATIC_LIBS 选项但没有更好的结果。这里发生了什么?我需要做什么?

最佳答案

好吧,我终于把一切都达到了我需要的状态。下面主要描述如何使用 Code::Blocks 在 Windows 7 上获取您想要的神奇 libCGAL.dll 和 libCGAL.a(库文件)。

  1. 我下载并安装了 CMake。
  2. 我下载并安装了 Boost 1.58.0,其中包括手册和 GMP(但不包括示例,因为我不想在 Qt 上游手好闲)。目的地是一个没有空格的文件夹。
  3. 我下载并安装了 CGAL-4.6。同样,目标是没有空格的文件夹。
  4. 我将 CodeBlocks\MingW\bin 添加到我的 PATH环境变量。
  5. 我进入 boost_1_58_0 文件夹,打开命令提示符,然后输入 bootstrap gcc , 其次是 b2 --toolset=gcc , 都好。这似乎将 Boost 构建到 stage\lib 文件夹中。
  6. 我创建了一个新的 Code::Blocks 项目来测试 Boost 文件。在项目构建选项中,我选择了根目录,在链接器设置下添加了一个到 libboost_regex-mgw44-mt-1_58.a 的直接路径。 ,在搜索目录下,我在编译器下添加了 boost_1_58_0 文件夹,在链接器下添加了 boost_1_58_0\stage\lib 文件夹。然后我成功编译并运行了示例正则表达式程序 here (第 6 节)。
  7. 我进入 CGAL-4.6 文件夹并打开命令提示符。我输入了 cmake-gui。我关注了this tutorial字面意思,除了我(认为)我选择了“指定 native 编译器”并将它们指向mingw32-gcc.exemingw32-g++.exe在 MingW 文件夹中(如果您已将 MingW\bin 添加到路径中,它可能会与第一个选项一起使用,就像您以后必须做的那样)
  8. 正确配置和构建后,创建了一个 Code::Blocks 项目文件以及一个 Makefile。 Code::Blocks 文件无用且无法正确构建,因为它试图运行 make.exe而不是 mingw32-make.exe .我不知道如何解决这个问题,所以我只是转到我的 Code::Blocks 文件夹,打开命令提示符并输入 mingw32-make.exe -s -f <path-to-the-makefile> all。 .它没有问题。
  9. 最后,我做了一个测试项目。与第 6 步一样,我添加了来自 Boost 的所有非调试库(stage/lib 中的 blah-blah-NOT-d.a)和来自 CGAL-4.6\lib 的 libCGAL.dll.a 库。我还添加了步骤 6 中的 Boost 目录,以及 CGAL-4.6\include 目录。
  10. 最后,我编译了示例here没有什么问题。在运行它之前。我不得不将 CGAL-4.6\bin\libCGAL.dll 移动到 exe 文件夹中,即 bin\Debug。

现在这已经非常简单了,不是吗?!

如果其他人遇到困难,请留言,我可以向您提供每个人都想要的实际文件:libCGAL.dll、libCGAL.dll.a、所有 Boost 库文件和所有 header 。

关于c++ - CMake 找不到 boost 库(CGAL、Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30089004/

相关文章:

c++ - 如何快速发送大量 POST 请求

c++ - 链接到共享的 boost 库让人头疼

java - 我们如何使用 Maven 发布 REST Web 服务的客户端 jar?连同 War 文件

android - AOSP ninja build 停止 : subcommand failed

c++关于在自身中嵌入结构名称的困惑

javascript - 第一次运行 Grunt build 时出错

c++ - 打印二维表(标题)

c++ - 具有 C++ 虚函数时的 GDB 不完整类型

c++ - 在 C++ 中实现高效的多线程文件 I/O

c++ - 带有 boost 1.50 : warning C4267 的 Visual Studio C++ 2005/2010