Alembic 编译

编者注

记录Alembic(三维中间件)的编译过程。

安装编译环境

安装Clion

安装MinGW

作者偷懒,直接下载DEVCpp,其中内置MinGW。路径为C:\Program Files (x86)\Dev-Cpp\MinGW64

CMake检查

Alemic项目检查

====================[ Build | abcdiff | Debug ]=================================
C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe --build C:\Workspace\Cpp\alembic\cmake-build-debug --target abcdiff -- -j 2
C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe -SC:\Workspace\Cpp\alembic -BC:\Workspace\Cpp\alembic\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
-- CMAKE SYSTEM NAME: Windows
-- The install dir is C:/Program Files (x86)/Alembic
ILMBASE_ROOT is undefined
CMake Error at cmake/Modules/FindIlmBase.cmake:157 (MESSAGE):
  ilmbase libraries (Half, Iex, IlmThread, Imath) not found, required
Call Stack (most recent call first):
  cmake/AlembicIlmBase.cmake:36 (FIND_PACKAGE)
  CMakeLists.txt:230 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "C:/Workspace/Cpp/alembic/cmake-build-debug/CMakeFiles/CMakeOutput.log".
Makefile:1092: recipe for target 'cmake_check_build_system' failed
mingw32-make.exe: *** [cmake_check_build_system] Error 1

通过CMake检查,和项目的readme可以了解到需要OpenEXR其中的一个Library

OpenEXR项目检查

C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Workspace\Cpp\openexr
-- Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR) 
CMake Warning at CMakeLists.txt:18 (message):
  Make Zlib available to CMake's search path, and re-run configuration


CMake Error at CMakeLists.txt:19 (message):
  Zlib is a required dependency when OPENEXR_BUILD_OPENEXR is set


-- Configuring incomplete, errors occurred!
See also "C:/Workspace/Cpp/openexr/cmake-build-debug/CMakeFiles/CMakeOutput.log".

[Finished]

看到OpenEXR项目需要Zlib库

Zlib库检查

C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Workspace\Cpp\zlib
-- The C compiler identification is GNU 4.9.2
-- Check for working C compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe
-- Check for working C compiler: C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Renaming
--     C:/Workspace/Cpp/zlib/zconf.h
-- to 'zconf.h.included' because this file is included with zlib
-- but CMake generates it automatically in the build directory.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Workspace/Cpp/zlib/cmake-build-debug

[Finished]

检查成功

倒序构建

Zlib构建

====================[ Build | example | Debug ]=================================
C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe --build C:\Workspace\Cpp\zlib\cmake-build-debug --target example -- -j 2
[  5%] Generating zlib1rc.obj
'C:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\windres.exe: preprocessing failed.
CMakeFiles\zlib.dir\build.make:60: recipe for target 'zlib1rc.obj' failed
mingw32-make.exe[3]: *** [zlib1rc.obj] Error 1
CMakeFiles\Makefile2:108: recipe for target 'CMakeFiles/zlib.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/zlib.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/example.dir/rule] Error 2
CMakeFiles\Makefile2:194: recipe for target 'CMakeFiles/example.dir/rule' failed
mingw32-make.exe: *** [example] Error 2
Makefile:213: recipe for target 'example' failed

说明命令行没有加双引号处理,尝试修改cmake失败,重新安装DevCpp到根目录下,编译成功,在项目下

zlib\cmake-build-debug\libzlib.dll    ---- 动态链接库
zlib\cmake-build-debug\libzlib.dll.a  ---- 静态链接库

OpenEXR构建

在CMake当中添加Zlib路径

set(ZLIB_INCLUDE_DIR "C:\\Workspace\\Cpp\\zlib\\cmake-build-debug")

接着提示找不到Python27

C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Workspace\Cpp\openexr
-- Found ZLIB: C:/Program Files/NOITOM/TranceMocap/zlib.dll  
-- Found PythonLibs: C:/Dev-Cpp/MinGW64/bin/python27.dll (found suitable version "2.7.15", minimum required is "2.7") 
-- Could NOT find Boost
CMake Warning at CMakeLists.txt:32 (message):
  user provided Boost Python27 was not found.  Trying default path...


-- Could NOT find Boost
CMake Warning at CMakeLists.txt:36 (message):
  Make boost Python available to CMake's search path, and re-run
  configuration


CMake Error at CMakeLists.txt:37 (message):
  boost Python is a required dependency when OPENEXR_BUILD_PYTHON_LIBS is set


-- Configuring incomplete, errors occurred!
See also "C:/Workspace/Cpp/openexr/cmake-build-debug/CMakeFiles/CMakeOutput.log".

[Finished]

由于本次并不编译OpenEXR的Python版本,则注释掉相关内容

#if (OPENEXR_BUILD_PYTHON_LIBS)
#  find_package(PythonLibs ${OPENEXR_PYTHON_MAJOR}.${OPENEXR_PYTHON_MINOR})
#  if(NOT PythonLibs_FOUND)
#    message(WARNING "Make Python ${OPENEXR_PYTHON_MAJOR}.${OPENEXR_PYTHON_MINOR} available to CMake's search path, and re-run configuration")
#    message(FATAL_ERROR "Python is a required dependency when OPENEXR_BUILD_PYTHON_LIBS is set")
#  endif()
#
#  find_package(Boost COMPONENTS python${OPENEXR_PYTHON_MAJOR}${OPENEXR_PYTHON_MINOR})
#  if(NOT Boost_PYTHON${OPENEXR_PYTHON_MAJOR}${OPENEXR_PYTHON_MINOR}_FOUND)
#    message(WARNING "user provided Boost Python${OPENEXR_PYTHON_MAJOR}${OPENEXR_PYTHON_MINOR} was not found. Trying default path...")
#
#    find_package(Boost COMPONENTS python)
#    if(NOT Boost_PYTHON_FOUND)
#      message(WARNING "Make boost Python available to CMake's search path, and re-run configuration")
#      message(FATAL_ERROR "boost Python is a required dependency when OPENEXR_BUILD_PYTHON_LIBS is set")
#    endif()
#  endif()
#
#  find_package(NumPy)
#endif()

以上方法错误,由于OpenEXR会自动刷新CMake文件,导致新写的配置丢失
通过查询发现cmake会找到cmake目录下的对应包的内容,目录如下

C:\Users\zhanp\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\183.5153.40\bin\cmake\win\share\cmake-3.13\Modules

找到FindZLIB.cmake,也就是说无需自己编写

A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
module where to look.

在FindZLIB.cmake当中添加

set(ZLIB_ROOT "C:\\Workspace\\Cpp\\zlib")

成功通过ZLIB的检测。

转载于:https://my.oschina.net/hava/blog/3008163

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值