首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >编译使用CMake到WebAssembly的大型WebAssembly项目

编译使用CMake到WebAssembly的大型WebAssembly项目
EN

Stack Overflow用户
提问于 2020-01-11 16:28:00
回答 1查看 2.5K关注 0票数 6

我一直试图编译一个大型C++项目,该项目使用CMake构建该项目,并将其编译为wasm。我几乎没有使用CMake文件的经验,而且我已经打了好几个月的仗了。

首先,我试着在我的机器上安装W组件编译器,遵循链接。我成功地安装了它,并运行了"hello world“项目。但是当A试图构建该项目时,将cmakemake命令更改为emcmakeemmake,但它开始抱怨缺少依赖库(boost和lua)。

然后,我尝试了一个码头映像,并构建了以下Dockerfile

代码语言:javascript
运行
复制
FROM trzeci/emscripten AS builder

RUN apt-get update && \
 apt-get install -y build-essential \
    cmake \
    git-core \
    libboost-atomic-dev \
    libboost-chrono-dev \
    libboost-date-time-dev \
    libboost-filesystem-dev \
    libboost-system-dev \
    libboost-thread-dev \
    libglew-dev \
    liblua5.1-0-dev \
    libncurses5-dev \
    libopenal-dev \
    libssl-dev \
    libvorbis-dev \
    mercurial \
    zlib1g-dev && \
 apt-get clean && apt-get autoclean

WORKDIR /
RUN hg clone -r stable-3.0 http://hg.icculus.org/icculus/physfs/
WORKDIR /physfs/build/
RUN cmake ..
RUN make -j$(nproc)
RUN make install

COPY ./src/ /otclient/src/.
COPY CMakeLists.txt /otclient/.
WORKDIR /otclient/build/
RUN emconfigure cmake -DCMAKE_CXX_LINK_FLAGS=-no-pie -DCMAKE_BUILD_TYPE=Release -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1 ..
RUN make -j$(nproc)

FROM trzeci/emscripten
RUN apt-get update; \
  apt-get install -y \
    libglew2.0 \
    libopenal1; \
  apt-get clean && apt-get autoclean
COPY --from=builder /otclient/build/otclient /otclient/bin/otclient
COPY ./data/ /otclient/data/.
COPY ./mods/ /otclient/mods/.
COPY ./modules/ /otclient/modules/.
COPY ./init.lua /otclient/.
WORKDIR /otclient
EXPOSE 8080:8080
RUN npm install http-server -g
CMD ["http-server", "./bin/", "-p", "8080"]

但同样的错误出现了,缺少了库。

代码语言:javascript
运行
复制
CMake Error at /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:2147 (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):
  src/framework/CMakeLists.txt:205 (find_package)
  CMakeLists.txt:36 (include)


CMake Error at /opt/cmake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Lua (missing: LUA_LIBRARY LUA_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/cmake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  src/framework/cmake/FindLua.cmake:17 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/framework/CMakeLists.txt:217 (find_package)
  CMakeLists.txt:36 (include)

我已经试着跟踪链接了,什么都没有。有CMake/WebAssembly经验的人能帮我吗?

项目链接是。CMake文件太大了不能在这里发布..。

在添加-DBoost_DEBUG=ON选项后编辑日志:

代码语言:javascript
运行
复制
Step 12/24 : RUN emconfigure cmake -DCMAKE_CXX_LINK_FLAGS=-no-pie -DCMAKE_BUILD_TYPE=Release -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1 -DBoost_DEBUG=ON ..
 ---> Running in e0ea96547712
CMake Error at CMakeLists.txt:21 (set):
  set given invalid arguments for CACHE mode.


-- Setting compilation target to WASM
CMake Warning (dev) at src/framework/CMakeLists.txt:152 (set):
  implicitly converting 'Git commit string (intended for releases)' to
  'STRING' type.
Call Stack (most recent call first):
  CMakeLists.txt:36 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at src/framework/CMakeLists.txt:153 (set):
  implicitly converting 'Git revision string (intended for releases)' to
  'STRING' type.
Call Stack (most recent call first):
  CMakeLists.txt:36 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test COMPILER_KNOWS_CXX11
-- Performing Test COMPILER_KNOWS_CXX11 - Success
-- Performing Test COMPILER_KNOWS_STDLIB
-- Performing Test COMPILER_KNOWS_STDLIB - Success
-- Link to static libraries: ON
-- Build type: Release
-- Build commit: devel
-- Build revision: 0
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1196 ] _boost_TEST_VERSIONS = 1.70.0;1.70;1.69.0;1.69;1.68.0;1.68;1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1198 ] Boost_USE_MULTITHREADED = ON
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1200 ] Boost_USE_STATIC_LIBS = ON
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1202 ] Boost_USE_STATIC_RUNTIME = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1204 ] Boost_ADDITIONAL_VERSIONS = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1206 ] Boost_NO_SYSTEM_PATHS = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1274 ] Declared as CMake or Environmental Variables:
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1276 ]   BOOST_ROOT = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1278 ]   BOOST_INCLUDEDIR = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1280 ]   BOOST_LIBRARYDIR = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1282 ] _boost_TEST_VERSIONS = 1.70.0;1.70;1.69.0;1.69;1.68.0;1.68;1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1357 ] Include debugging info:
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1359 ]   _boost_INCLUDE_SEARCH_DIRS = PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1361 ]   _boost_PATH_SUFFIXES = boost-1_70_0;boost_1_70_0;boost/boost-1_70_0;boost/boost_1_70_0;boost-1_70;boost_1_70;boost/boost-1_70;boost/boost_1_70;boost-1_69_0;boost_1_69_0;boost/boost-1_69_0;boost/boost_1_69_0;boost-1_69;boost_1_69;boost/boost-1_69;boost/boost_1_69;boost-1_68_0;boost_1_68_0;boost/boost-1_68_0;boost/boost_1_68_0;boost-1_68;boost_1_68;boost/boost-1_68;boost/boost_1_68;boost-1_67_0;boost_1_67_0;boost/boost-1_67_0;boost/boost_1_67_0;boost-1_67;boost_1_67;boost/boost-1_67;boost/boost_1_67;boost-1_66_0;boost_1_66_0;boost/boost-1_66_0;boost/boost_1_66_0;boost-1_66;boost_1_66;boost/boost-1_66;boost/boost_1_66;boost-1_65_1;boost_1_65_1;boost/boost-1_65_1;boost/boost_1_65_1;boost-1_65_0;boost_1_65_0;boost/boost-1_65_0;boost/boost_1_65_0;boost-1_65;boost_1_65;boost/boost-1_65;boost/boost_1_65;boost-1_64_0;boost_1_64_0;boost/boost-1_64_0;boost/boost_1_64_0;boost-1_64;boost_1_64;boost/boost-1_64;boost/boost_1_64;boost-1_63_0;boost_1_63_0;boost/boost-1_63_0;boost/boost_1_63_0;boost-1_63;boost_1_63;boost/boost-1_63;boost/boost_1_63;boost-1_62_0;boost_1_62_0;boost/boost-1_62_0;boost/boost_1_62_0;boost-1_62;boost_1_62;boost/boost-1_62;boost/boost_1_62;boost-1_61_0;boost_1_61_0;boost/boost-1_61_0;boost/boost_1_61_0;boost-1_61;boost_1_61;boost/boost-1_61;boost/boost_1_61;boost-1_60_0;boost_1_60_0;boost/boost-1_60_0;boost/boost_1_60_0;boost-1_60;boost_1_60;boost/boost-1_60;boost/boost_1_60;boost-1_59_0;boost_1_59_0;boost/boost-1_59_0;boost/boost_1_59_0;boost-1_59;boost_1_59;boost/boost-1_59;boost/boost_1_59;boost-1_58_0;boost_1_58_0;boost/boost-1_58_0;boost/boost_1_58_0;boost-1_58;boost_1_58;boost/boost-1_58;boost/boost_1_58;boost-1_57_0;boost_1_57_0;boost/boost-1_57_0;boost/boost_1_57_0;boost-1_57;boost_1_57;boost/boost-1_57;boost/boost_1_57;boost-1_56_0;boost_1_56_0;boost/boost-1_56_0;boost/boost_1_56_0;boost-1_56;boost_1_56;boost/boost-1_56;boost/boost_1_56;boost-1_55_0;boost_1_55_0;boost/boost-1_55_0;boost/boost_1_55_0;boost-1_55;boost_1_55;boost/boost-1_55;boost/boost_1_55;boost-1_54_0;boost_1_54_0;boost/boost-1_54_0;boost/boost_1_54_0;boost-1_54;boost_1_54;boost/boost-1_54;boost/boost_1_54;boost-1_53_0;boost_1_53_0;boost/boost-1_53_0;boost/boost_1_53_0;boost-1_53;boost_1_53;boost/boost-1_53;boost/boost_1_53;boost-1_52_0;boost_1_52_0;boost/boost-1_52_0;boost/boost_1_52_0;boost-1_52;boost_1_52;boost/boost-1_52;boost/boost_1_52;boost-1_51_0;boost_1_51_0;boost/boost-1_51_0;boost/boost_1_51_0;boost-1_51;boost_1_51;boost/boost-1_51;boost/boost_1_51;boost-1_50_0;boost_1_50_0;boost/boost-1_50_0;boost/boost_1_50_0;boost-1_50;boost_1_50;boost/boost-1_50;boost/boost_1_50;boost-1_49_0;boost_1_49_0;boost/boost-1_49_0;boost/boost_1_49_0;boost-1_49;boost_1_49;boost/boost-1_49;boost/boost_1_49;boost-1_48_0;boost_1_48_0;boost/boost-1_48_0;boost/boost_1_48_0;boost-1_48;boost_1_48;boost/boost-1_48;boost/boost_1_48
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1462 ] Boost_LIB_PREFIX = 
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1464 ] Boost_NAMESPACE = boost
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1499 ] guessed _boost_COMPILER = -clang60
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1509 ] _boost_MULTITHREADED = -mt
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1593 ] _boost_RELEASE_ABI_TAG = -
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1595 ] _boost_DEBUG_ABI_TAG = -d
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1658 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = Boost_INCLUDE_DIR-NOTFOUND/lib;Boost_INCLUDE_DIR-NOTFOUND/../lib;Boost_INCLUDE_DIR-NOTFOUND/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG   = Boost_INCLUDE_DIR-NOTFOUND/lib;Boost_INCLUDE_DIR-NOTFOUND/../lib;Boost_INCLUDE_DIR-NOTFOUND/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1852 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-clang60-mt-;boost_system-clang60-mt;boost_system-clang60-mt;boost_system-mt-;boost_system-mt;boost_system-mt;boost_system-mt;boost_system
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1909 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-clang60-mt-d-;boost_system-clang60-mt-d;boost_system-clang60-mt-d;boost_system-mt-d-;boost_system-mt-d;boost_system-mt-d;boost_system-mt;boost_system
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1852 ] Searching for THREAD_LIBRARY_RELEASE: boost_thread-clang60-mt-;boost_thread-clang60-mt;boost_thread-clang60-mt;boost_thread-mt-;boost_thread-mt;boost_thread-mt;boost_thread-mt;boost_thread
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1909 ] Searching for THREAD_LIBRARY_DEBUG: boost_thread-clang60-mt-d-;boost_thread-clang60-mt-d;boost_thread-clang60-mt-d;boost_thread-mt-d-;boost_thread-mt-d;boost_thread-mt-d;boost_thread-mt;boost_thread
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1852 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-clang60-mt-;boost_filesystem-clang60-mt;boost_filesystem-clang60-mt;boost_filesystem-mt-;boost_filesystem-mt;boost_filesystem-mt;boost_filesystem-mt;boost_filesystem
-- [ /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:1909 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-clang60-mt-d-;boost_filesystem-clang60-mt-d;boost_filesystem-clang60-mt-d;boost_filesystem-mt-d-;boost_filesystem-mt-d;boost_filesystem-mt-d;boost_filesystem-mt;boost_filesystem
CMake Error at /opt/cmake/share/cmake-3.14/Modules/FindBoost.cmake:2147 (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):
  src/framework/CMakeLists.txt:205 (find_package)
  CMakeLists.txt:36 (include)


CMake Error at /opt/cmake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Lua (missing: LUA_LIBRARY LUA_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/cmake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  src/framework/cmake/FindLua.cmake:17 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/framework/CMakeLists.txt:217 (find_package)
  CMakeLists.txt:36 (include)


-- Configuring incomplete, errors occurred!
See also "/otclient/build/CMakeFiles/CMakeOutput.log".
The command '/bin/sh -c emconfigure cmake -DCMAKE_CXX_LINK_FLAGS=-no-pie -DCMAKE_BUILD_TYPE=Release -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1 -DBoost_DEBUG=ON ..' returned a non-zero code: 1
EN

回答 1

Stack Overflow用户

发布于 2020-01-28 07:44:39

我遇到了同样的问题,我认为这与这个“征文”问题有关:

https://github.com/emscripten-core/emscripten/issues/10078

FindBoost.cmake调用find_path()来查找boost/config.hpp在许多可选路径中的位置(在HINTS它是路径的同义词中指定)

显然,目前在Emscripten (我使用的是1.39.6版本)中存在一个bug,因为它不尊重PATHS/HINTS变量。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59696327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档