Web アプリケーションに変換したい C++ プロジェクトがあります。この目的のために、Emscripten を使用してプロジェクトをビルドしたいと考えています。
プロジェクトは、いくつかの外部ライブラリを使用します。私はほとんどのライブラリのJavaScriptバージョンをコンパイルまたは見つけることができましたが、今はBoostのもので立ち往生しています。実際、Boost の開始方法も知りません。Boostrap スクリプトを使用してファイルを生成し、ライブラリを構築します。ツールセットをこのスクリプトに渡すことは可能ですが、Emscripten は明らかにサポートされていません。
私のプロジェクトでは、Boost の次の部分を使用しています: Thread、Regex、FileSystem、Signals、System。Emscripten を使用してこれらのライブラリをコンパイルするにはどうすればよいですか?
編集
npclaudiu の回答に従って、ライブラリを gcc ツールキットでブートストラップし、編集project-config.jam
してコンパイラを構成し、以下を置き換えました。
# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! gcc in [ feature.values <toolset> ]
{
using gcc ;
}
と
# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! gcc in [ feature.values <toolset> ]
{
using gcc : : "/full/path/to/em++" ;
}
これで、入力によって./b2
効率的にライブラリが構築されます。Boost.Signals と Boost.System は適切にコンパイルされます。他は若干の誤差があります。
Boost.Thread は不平を言います:
libs/thread/src/pthread/thread.cpp:503:27: error: use of undeclared identifier 'pthread_yield'
BOOST_VERIFY(!pthread_yield());
^
Boost.Regex は、CHAR_BIT が宣言されていないことについて多くの不平を言っていますが、emscripten では問題のようです:
In file included from libs/regex/build/../src/c_regex_traits.cpp:28:
In file included from ./boost/regex/v4/c_regex_traits.hpp:26:
In file included from ./boost/regex/v4/regex_workaround.hpp:35:
/path/to/emscripten/system/include/libcxx/vector:1989:92: error: use of undeclared identifier 'CHAR_BIT'
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
^
Boost.FileSystem も emscripten が原因で失敗するようです:
In file included from libs/filesystem/src/windows_file_codecvt.cpp:21:
/path/to/emscripten/system/include/libcxx/cwchar:117:9: error: no member named 'FILE' in the global namespace
using ::FILE;
~~^