wohenyingyu01
V2EX  ›  程序员

在 Mac 上编译英雄无敌 3 死亡阴影遇到一点问题,请熟悉 cmake 的大侠不惜赐教,附上 github 地址

By wohenyingyu01 at 2015 年 10 月 5 日 · 9468 次点击
代码地址:
git clone https://github.com/vcmi/vcmi.git

vcmi 是英雄无敌 3 的开源引擎,根据官方论坛的说法,只要将其在 mac 上编译出来,然后把原来死亡阴影的 data , map 等包复制到根目录就能玩 mac 版啦。因为官方不提供现成的编译好的包(只有 win 的)无聊来试一试:)

官方 readme 流程:
mkdir vcmi && cd vcmi
git clone https://github.com/vcmi/vcmi.git
cd vcmi
sh osx/download_dependencies.sh
mkdir build && cd build
cmake -G Xcode .. -DENABLE_LAUNCHER=OFF
open vcmi.xcodeproj

说明上说只要有 vcmi 代码和 cmake 就可以了。
我在执行 cmake 的时候提示找不到 boost , minizip 和 sdl2 库,应该是没有环境,本来在 brew 里面都可以下载到这些包,但是我仔细看了 download_dependencies.sh 发现它下载的东西正是这些包,但是 cmake 不知什么原因没有找到,谷歌也半天不知道如何让 cmake 往指定的文件夹找 dependencies ?求教
33 条回复  •  2016-06-21 10:43:23 +08:00
onlyxuyang
   1
onlyxuyang  
   2015 年 10 月 5 日 via Android
…… wog 啊啊啊 感谢楼主找到了这个 project …… 啊啊啊啊啊 赞 英雄无敌③ 赞
zjwzszh
   2
zjwzszh  
   2015 年 10 月 5 日
挖哈哈哈哈,居然有 mac 版的啊!!!!!!
kevinyoung
   3
kevinyoung  
   2015 年 10 月 5 日
楼主升 El Capitan 没? 新系统的根目录权限给改了,有可能这些依赖的库就装不上了,如果是这个原因导致的,要么等官方出来修改安装脚本,要么用 home brew 试试
squid157
   4
squid157  
   2015 年 10 月 5 日 via iPhone
话说……新的 HD 版 数据格式一样么 老版都是盗版不好找了
wohenyingyu01
   5
wohenyingyu01  
OP
   2015 年 10 月 5 日
@kevinyoung 升级了,然后 home-brew 就用不了了,我得重新去获取 brew 目录的权限 chown = =
但是这个依赖库是倒数第四行的 download_dependencies.sh 脚本自动下载的,放在根目录的 lib 文件夹下面,不知道为什么 cmake 找不到。
wohenyingyu01
   6
wohenyingyu01  
OP
   2015 年 10 月 5 日
@squid157 官方要求貌似要死亡阴影或者 wog 的版本, hd 只有埃莱西亚的光复吧?不过官方提供了个老版的购买地址就几美元
wohenyingyu01
   7
wohenyingyu01  
OP
   2015 年 10 月 5 日
附上 output 吧:

Stevens-MacBook-Air:build Steven$ cmake -G Xcode .. -DENABLE_LAUNCHER=OFF
-- The C compiler identification is AppleClang 7.0.0.7000072
-- The CXX compiler identification is AppleClang 7.0.0.7000072
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for shm_open in rt
-- Looking for shm_open in rt - not found
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindBoost.cmake:1245 (message):
Unable to find the requested Boost libraries.

Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:118 (find_package)


-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.5")
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28")
-- checking for module 'libavcodec'
-- package 'libavcodec' not found
-- checking for module 'libavformat'
-- package 'libavformat' not found
-- checking for module 'libavdevice'
-- package 'libavdevice' not found
-- checking for module 'libavutil'
-- package 'libavutil' not found
-- checking for module 'libswscale'
-- package 'libswscale' not found
-- checking for module 'libpostproc'
-- package 'libpostproc' not found
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find FFmpeg (missing: FFMPEG_INCLUDE_DIRS AVCODEC_LIBRARIES
AVCODEC_INCLUDE_DIRS AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIRS
AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS SWSCALE_LIBRARIES
SWSCALE_INCLUDE_DIRS)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake_modules/FindFFmpeg.cmake:163 (find_package_handle_standard_args)
CMakeLists.txt:120 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/Steven/Xcode/vcmi-develop/build/CMakeFiles/CMakeOutput.log".
See also "/Users/Steven/Xcode/vcmi-develop/build/CMakeFiles/CMakeError.log".
Stevens-MacBook-Air:build Steven$ ls
CMakeCache.txt CMakeFiles
Stevens-MacBook-Air:build Steven$ rm CMakeCache.txt
Stevens-MacBook-Air:build Steven$ rm -rf CMakeFiles/
Stevens-MacBook-Air:build Steven$ sudo cmake -G Xcode .. -DENABLE_LAUNCHER=OFF
Password:
-- The C compiler identification is AppleClang 7.0.0.7000072
-- The CXX compiler identification is AppleClang 7.0.0.7000072
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for shm_open in rt
-- Looking for shm_open in rt - not found
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindBoost.cmake:1245 (message):
Unable to find the requested Boost libraries.

Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:118 (find_package)


-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.5")
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28")
-- checking for module 'libavcodec'
-- package 'libavcodec' not found
-- checking for module 'libavformat'
-- package 'libavformat' not found
-- checking for module 'libavdevice'
-- package 'libavdevice' not found
-- checking for module 'libavutil'
-- package 'libavutil' not found
-- checking for module 'libswscale'
-- package 'libswscale' not found
-- checking for module 'libpostproc'
-- package 'libpostproc' not found
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find FFmpeg (missing: FFMPEG_INCLUDE_DIRS AVCODEC_LIBRARIES
AVCODEC_INCLUDE_DIRS AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIRS
AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS SWSCALE_LIBRARIES
SWSCALE_INCLUDE_DIRS)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake_modules/FindFFmpeg.cmake:163 (find_package_handle_standard_args)
CMakeLists.txt:120 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/Steven/Xcode/vcmi-develop/build/CMakeFiles/CMakeOutput.log".
See also "/Users/Steven/Xcode/vcmi-develop/build/CMakeFiles/CMakeError.log".
squid157
   8
squid157  
   2015 年 10 月 5 日 via iPhone
@squid157 gog 上面买是吧
zhonghua
   9
zhonghua  
   2015 年 10 月 5 日 via Android
我前段时间也搞了一阵。。。
wohenyingyu01
   10
wohenyingyu01  
OP
   2015 年 10 月 5 日
@zhonghua 弄出来了么
secondwtq
   11
secondwtq  
   2015 年 10 月 5 日
在我这 Boost 是正常可以找到的( unlink 掉了 brew 装的那份,确认了 Cache 里面的路径)。

FFmpeg 如果要用它下载的包里面那份的话,最好把 cmake_modules/FindFFmpeg.cmake 里面关于 pkgconfig 那几行注释掉,不然它会在 pkgconfig 里面找,自然找不到。
huangji
   12
huangji  
   2015 年 10 月 5 日
加油!
tracyone
   13
tracyone  
   2015 年 10 月 5 日
@wohenyingyu01 error 里面提示缺少 ffmpeg 相关的东西,我现在还不熟悉 osx ,不过你可以谷歌下如何在 osx 装 ffmpge 还有其库,应该就可以解决这个问题了。
MCVector
   14
MCVector  
   2015 年 10 月 5 日 via Android
在 ubuntu 上试了一下顺利编译通过, mac 上还没来得及试
beyondsoft
   15
beyondsoft  
   2015 年 10 月 5 日
@wohenyingyu01 我发现似乎是这个文件里面指定的
cmake_modules/FindFFmpeg.cmake

# Once done this will define
# FFMPEG_FOUND - System has the all required components.
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
wohenyingyu01
   16
wohenyingyu01  
OP
   2015 年 10 月 5 日
@secondwtq
我的 brew 除了 pkg-config 和 cmake 之外没有装其他的,我发现最顶层的 CMakeLists.txt 就有问题,库的路径根本就不对,似乎 cmake 就是由这个配置文件来检查环境并生成 makefile 的:
if (APPLE)
# Default location for thirdparty libs
set(CMAKE_INCLUDE_PATH "../include" "${CMAKE_OSX_SYSROOT}/usr/include")
set(CMAKE_LIBRARY_PATH "../lib")
set(CMAKE_FRAMEWORK_PATH "../Frameworks")
set(BOOST_ROOT "../")

将其改为:
if (APPLE)
# Default location for thirdparty libs
set(CMAKE_INCLUDE_PATH "./include" "${CMAKE_OSX_SYSROOT}/usr/include")
set(CMAKE_LIBRARY_PATH "./lib")
set(CMAKE_FRAMEWORK_PATH "./Frameworks")
set(BOOST_ROOT "./lib")
set(MINIZIP_LIBRARY "./lib/minizip")
可以顺利识别 boost , minizip 和 FFmpeg ,不明白你的为啥就没问题。。。但是这样改后依然还有好多库没识别,待研究。
wohenyingyu01
   17
wohenyingyu01  
OP
   2015 年 10 月 5 日
@tracyone 嗯嗯谢谢,我已经解决 ffmpeg 了,还有其他一些依赖库,再研究看看
wohenyingyu01
   18
wohenyingyu01  
OP
   2015 年 10 月 5 日
@beyondsoft 嗯是的,但是这个东西只要在最上层的 CMakeLists.txt 配置文件里面包含进去就好, vcmi 包里面都有的,现在还有一个库没解决:
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find SDL2 (missing: SDL2_LIBRARY) (found version "1.2.15")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake_modules/FindSDL2.cmake:214 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:126 (find_package)
zhonghua
   19
zhonghua  
   2015 年 10 月 5 日 via Android
@wohenyingyu01 有别的事耽误了
secondwtq
   20
secondwtq  
   2015 年 10 月 6 日
@wohenyingyu01 大概是因为他寻找的文件名是 SDL2 ,然而他 bundle 的 framework 里面并没有。

SDL 这东西不是很熟悉,不过好像下下来的 framework 怎么看都不像 SDL2.
MrYELiex
   21
MrYELiex  
   2015 年 10 月 6 日
编译不需要手动下载依赖的吖 都会有个脚本处理依赖的
edwardaa
   22
edwardaa  
   2015 年 10 月 6 日
强烈支持
kyrre
   23
kyrre  
   2016 年 1 月 4 日
@wohenyingyu01 , 后来编出来了吗?
我照着 http://wiki.vcmi.eu/index.php?title=How_to_build_VCMI_(OS_X)做可以成功编译。但是它的上面没有提其实还是需要 ffmpeg 这个依赖的,用 homebrew 装一下就可以了。
但是玩的话需要原来的 iso 或安装文件,这个就不好找了。几天下班了回去翻翻看。
wohenyingyu01
   24
wohenyingyu01  
OP
   2016 年 1 月 5 日
@kyrre 是不需要自己装 ffmpeg 这个依赖的,仔细看看就会发现在 download_dependencies.sh 的脚本里面已经下载好了,当然自己装 ffmpeg 也是可以的,就是小概率会有版本问题
kyrre
   25
kyrre  
   2016 年 1 月 7 日
@wohenyingyu01 这个我倒是没去看。你后来玩上了吗?准备周末折腾一下。
wohenyingyu01
   26
wohenyingyu01  
OP
   2016 年 1 月 7 日
@kyrre 工作了年纪大了没心力折腾了……成功了记得来分享下成果~
kyrre
   27
kyrre  
   2016 年 1 月 7 日
@wohenyingyu01 没问题!我还看到个帝国时代 2 的开源版的,叫 openage , github 上有源码。等我折腾完这个再去折腾它。
kyrre
   28
kyrre  
   2016 年 1 月 11 日
@wohenyingyu01 启动时报错, google 了一下好像是那个自动更新框架的问题。😢
meizhile
   29
meizhile  
   2016 年 6 月 20 日
@kyrre
我也是照 wiki 说明编译成功了,但是在加载 iso 时遇到了和下面这个链接一样的错误,不知道你解决了吗?错误信息:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
链接: http://bugs.vcmi.eu/view.php?id=2432#bugnotes
kyrre
   30
kyrre  
   2016 年 6 月 21 日 via iPad
@meizhile 我还没到你这一步就挂了……
wohenyingyu01
   31
wohenyingyu01  
OP
   2016 年 6 月 21 日 via iPhone
@meizhile 这个不是没有强制使用 https 的报错么
meizhile
   32
meizhile  
   2016 年 6 月 21 日
@wohenyingyu01 不清楚为什么,只是读取本地磁盘的 ISO 文件就报这个错误,你看下面的 bug 链接里也是相同的情况,猜想代码里可能有和服务器通信内容吧
meizhile
   33
meizhile  
   2016 年 6 月 21 日
那个 bug 也没官方回复,并不知道怎么修改,能搜到的也都是 iOS 相关报错的资料,是有关 https 的
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
© 2026 V2EX · 64ms · 3.9.8.5