2

我正在尝试使用 emscripten 将一些项目编译为 js。该项目使用 cmake 作为构建工具。

这就是我调用 cmake 的方式:

cmake -DEMSCRIPTEN=1 
-DCMAKE_TOOLCHAIN_FILE=~/Documents/emscripten/cmake/Platform/Emscripten_unix.cmake
-DCMAKE_MODULE_PATH=~/Documents/emscripten/cmake 
-DCMAKE_BUILD_TYPE=Release 
-G "Unix Makefiles" 
-DRDK_BUILD_PYTHON_WRAPPERS= 
-DBOOST_INCLUDEDIR=~/Documents/boost_1_53_0/boost 
-DBOOST_LIBRARYDIR=~/Documents/boost_1_53_0/stage/lib 
-DBoost_REGEX_LIBRARY=~/Documents/boost_1_53_0/stage/lib/libboost_regex.a 
-DBOOST_ROOT=~/Documents/boost_1_53_0 
-DBoost_NO_SYSTEM_PATHS=TRUE 
-DBoost_USE_MULTITHREADED=FALSE 
-DBoost_USE_STATIC_LIBS=OFF 
-DBoost_USE_STATIC_RUNTIME=OFF 
-DBoost_ADDITIONAL_VERSIONS="1.53.0" 
-DBoost_DETAILED_FAILURE_MSG=TRUE 
-DBoost_NO_BOOST_CMAKE=ON 
-DBoost_DEBUG=TRUE 
..

这就是我在 /home/mnowotka/Documents/boost_1_53_0/stage/lib 目录中的内容:

ls -lh ~/Documents/boost_1_53_0/stage/lib
total 4.4M
-rw-rw-r-- 1 mnowotka mnowotka 2.6M Apr 11 10:49 libboost_regex.a
lrwxrwxrwx 1 mnowotka mnowotka   24 Apr 11 10:10 libboost_regex.so -> libboost_regex.so.1.53.0
-rw-rw-r-- 1 mnowotka mnowotka 1.9M Apr 11 10:10 libboost_regex.so.1.53.0

这就是我从 cmake 得到的:

-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:667 ] Include debugging info:
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:669 ]   _boost_INCLUDE_SEARCH_DIRS = /home/mnowotka/Documents/boost_1_53_0/boost;/home/mnowotka/Documents/boost_1_53_0/include;/home/mnowotka/Documents/boost_1_53_0
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:671 ]   _boost_PATH_SUFFIXES = boost-1_53_0;boost_1_53_0;boost-1_48_0;boost_1_48_0;boost-1_48;boost_1_48;boost-1_47_0;boost_1_47_0;boost-1_47;boost_1_47;boost-1_46_1;boost_1_46_1;boost-1_46_0;boost_1_46_0;boost-1_46;boost_1_46;boost-1_45_0;boost_1_45_0;boost-1_45;boost_1_45;boost-1_44_0;boost_1_44_0;boost-1_44;boost_1_44;boost-1_43_0;boost_1_43_0;boost-1_43;boost_1_43;boost-1_42_0;boost_1_42_0;boost-1_42;boost_1_42;boost-1_41_0;boost_1_41_0;boost-1_41;boost_1_41;boost-1_40_0;boost_1_40_0;boost-1_40;boost_1_40;boost-1_39_0;boost_1_39_0;boost-1_39;boost_1_39
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:696 ] location of version.hpp: /home/mnowotka/Documents/boost_1_53_0/boost/version.hpp
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:715 ] version.hpp reveals boost 1.53.0
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:808 ] guessed _boost_COMPILER = 
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:818 ] _boost_MULTITHREADED = 
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:861 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:863 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:906 ] _boost_LIBRARY_SEARCH_DIRS = /home/mnowotka/Documents/boost_1_53_0/stage/lib;/home/mnowotka/Documents/boost_1_53_0/lib;/home/mnowotka/Documents/boost_1_53_0/stage/lib;/home/mnowotka/Documents/boost_1_53_0/lib;/home/mnowotka/Documents/boost_1_53_0/../lib;/home/mnowotka/Documents/boost_1_53_0/stage/lib
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1119 ] Boost_FOUND = TRUE
-- Boost version: 1.53.0
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found BISON: /usr/bin/bison 
-- Found FLEX: /usr/bin/flex 
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:525 ] Boost not in cache
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:528 ] _boost_TEST_VERSIONS = 1.53.0;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:530 ] Boost_USE_MULTITHREADED = FALSE
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:532 ] Boost_USE_STATIC_LIBS = OFF
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:534 ] Boost_USE_STATIC_RUNTIME = OFF
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:536 ] Boost_ADDITIONAL_VERSIONS = 1.53.0
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:538 ] Boost_NO_SYSTEM_PATHS = TRUE
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:606 ] Declared as CMake or Environmental Variables:
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:608 ]   BOOST_ROOT = /home/mnowotka/Documents/boost_1_53_0
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:610 ]   BOOST_INCLUDEDIR = /home/mnowotka/Documents/boost_1_53_0/boost
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:612 ]   BOOST_LIBRARYDIR = /home/mnowotka/Documents/boost_1_53_0/stage/lib
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:614 ] _boost_TEST_VERSIONS = 1.53.0;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:696 ] location of version.hpp: /home/mnowotka/Documents/boost_1_53_0/boost/version.hpp
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:715 ] version.hpp reveals boost 1.53.0
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:808 ] guessed _boost_COMPILER = 
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:818 ] _boost_MULTITHREADED = 
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:861 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:863 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:906 ] _boost_LIBRARY_SEARCH_DIRS = /home/mnowotka/Documents/boost_1_53_0/stage/lib;/home/mnowotka/Documents/boost_1_53_0/lib;/home/mnowotka/Documents/boost_1_53_0/stage/lib;/home/mnowotka/Documents/boost_1_53_0/lib;/home/mnowotka/Documents/boost_1_53_0/../lib;/home/mnowotka/Documents/boost_1_53_0/stage/lib
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:977 ] Searching for REGEX_LIBRARY_RELEASE: boost_regex-1_53;boost_regex;boost_regex-1_53;boost_regex;boost_regex
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1009 ] Searching for REGEX_LIBRARY_DEBUG: boost_regex-d-1_53;boost_regex-d;boost_regex-d-1_53;boost_regex-d;boost_regex;boost_regex
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1119 ] Boost_FOUND = FALSE
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1202 (message):
Unable to find the requested Boost libraries.

Boost version: 1.53.0

Boost include path: /home/mnowotka/Documents/boost_1_53_0

The following Boost libraries could not be found:

      boost_regex

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):
Code/GraphMol/SLNParse/CMakeLists.txt:4 (find_package)


CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_REGEX_LIBRARY (ADVANCED)
linked by target "testSLNParse" in directory /home/mnowotka/Documents/rdkit-code/Code/GraphMol/SLNParse

-- Configuring incomplete, errors occurred!

我只有一个问题:为什么?

我做错了什么?这让我发疯......

(顺便说一句:如果我设置Boost_USE_STATIC_LIBSBoost_USE_STATIC_RUNTIME ONOFF- 它也不起作用......)

4

1 回答 1

2
  1. 您知道,Emscripten目前只能使用它编译的源代码的模块(例如BoostBoost-Regex )吗?换句话说,Emscripten不能使用动态库或预编译的静态库!

    • 因此,您必须将Boost-Regex的源代码添加到您的cmake文件中并将它们一起构建(我已经有一段时间没有完成cmake ,所以我无法告诉您如何操作)。

    • 或者您可以从cmake中删除对Boost-Regex的检查并硬编码必要的参考

    无论您选择做什么,您都必须使用Emscripten构建Boost-Regex

  2. 至于Emscripten,您应该真正使用,因为EmscriptenBoost_USE_STATIC_LIBS=ON目前不支持动态库(见上文)。

  3. Emscripten也不支持调用pthread*或任何并发处理。您应该在代码中搜索这些内容。

很抱歉听起来如此消极,但目前使用带有Emscripten的库可不是小菜一碟。

于 2013-04-12T16:13:08.367 回答