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

2015-10-05 01:29:55 +08:00
 wohenyingyu01
代码地址:
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 ?求教
7877 次点击
所在节点    程序员
33 条回复
onlyxuyang
2015-10-05 07:17:35 +08:00
…… wog 啊啊啊 感谢楼主找到了这个 project …… 啊啊啊啊啊 赞 英雄无敌③ 赞
zjwzszh
2015-10-05 08:57:58 +08:00
挖哈哈哈哈,居然有 mac 版的啊!!!!!!
kevinyoung
2015-10-05 10:38:11 +08:00
楼主升 El Capitan 没? 新系统的根目录权限给改了,有可能这些依赖的库就装不上了,如果是这个原因导致的,要么等官方出来修改安装脚本,要么用 home brew 试试
squid157
2015-10-05 10:46:29 +08:00
话说……新的 HD 版 数据格式一样么 老版都是盗版不好找了
wohenyingyu01
2015-10-05 10:51:51 +08:00
@kevinyoung 升级了,然后 home-brew 就用不了了,我得重新去获取 brew 目录的权限 chown = =
但是这个依赖库是倒数第四行的 download_dependencies.sh 脚本自动下载的,放在根目录的 lib 文件夹下面,不知道为什么 cmake 找不到。
wohenyingyu01
2015-10-05 10:53:31 +08:00
@squid157 官方要求貌似要死亡阴影或者 wog 的版本, hd 只有埃莱西亚的光复吧?不过官方提供了个老版的购买地址就几美元
wohenyingyu01
2015-10-05 11:03:06 +08:00
附上 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
2015-10-05 11:19:02 +08:00
@squid157 gog 上面买是吧
zhonghua
2015-10-05 11:56:53 +08:00
我前段时间也搞了一阵。。。
wohenyingyu01
2015-10-05 13:49:14 +08:00
@zhonghua 弄出来了么
secondwtq
2015-10-05 13:50:53 +08:00
在我这 Boost 是正常可以找到的( unlink 掉了 brew 装的那份,确认了 Cache 里面的路径)。

FFmpeg 如果要用它下载的包里面那份的话,最好把 cmake_modules/FindFFmpeg.cmake 里面关于 pkgconfig 那几行注释掉,不然它会在 pkgconfig 里面找,自然找不到。
huangji
2015-10-05 15:53:02 +08:00
加油!
tracyone
2015-10-05 16:43:14 +08:00
@wohenyingyu01 error 里面提示缺少 ffmpeg 相关的东西,我现在还不熟悉 osx ,不过你可以谷歌下如何在 osx 装 ffmpge 还有其库,应该就可以解决这个问题了。
MCVector
2015-10-05 20:54:16 +08:00
在 ubuntu 上试了一下顺利编译通过, mac 上还没来得及试
beyondsoft
2015-10-05 21:15:16 +08:00
@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
2015-10-05 22:43:40 +08:00
@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
2015-10-05 22:44:49 +08:00
@tracyone 嗯嗯谢谢,我已经解决 ffmpeg 了,还有其他一些依赖库,再研究看看
wohenyingyu01
2015-10-05 22:46:50 +08:00
@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
2015-10-05 23:13:22 +08:00
@wohenyingyu01 有别的事耽误了
secondwtq
2015-10-06 00:34:48 +08:00
@wohenyingyu01 大概是因为他寻找的文件名是 SDL2 ,然而他 bundle 的 framework 里面并没有。

SDL 这东西不是很熟悉,不过好像下下来的 framework 怎么看都不像 SDL2.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/225649

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX