如何在使用Emscripten emcc并在Mac上制作时包含ncurses [英] How to include ncurses while using Emscripten emcc and make on Mac

查看:823
本文介绍了如何在使用Emscripten emcc并在Mac上制作时包含ncurses的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个项目(即Angband的来源 - http://rephial.org/downloads/3.3/angband-v3.3.2.tar.gz )与Emscripten的emcc,以便将其移植到Javascript并最终构建在线版本。



我设法让流程开始于

emconfigure ./configure
make



开始成功地开始生成LLVM bitcode .o文件,但随后它在main-gcu.c上挂起,并带有'main-gcu.c:43:11:致命错误:'ncurses.h'文件未找到'



我相信main-gcu.c是唯一引用ncurses的文件,但我无法弄清楚在编译时如何包含这个库。有没有一种方法来指定包含'make'的ncurses,还是应该使用'emcc main-gcu.c -c -lncurses'来单独编译main-gcu.c文件?我试图这样做,但这导致了另一个错误与emcc无法找到其他实际包括的头文件两个级别下来(它找不到头包含在main-gcu.c包含头 - 无论如何修复? )。



我也不确定是否需要在Mac OSX上安装ncurses库。所有我真正能够找到的都是对Linux的libncurses5-dev的引用。



谢谢!

解决方案

我认为你误解了通过 Emscripten 进行编译。我会尽力指出你遇到的一些问题。


  1. 一般规则是所有的工具 Emscripten 可以将 LLVM 格式 。 emconfigure emmake ... 修改构建环境以便您的源代码被编译为其中一种 LLVM 格式(规则有例外,但从来都不是)。因此,任何你想链接到最终结果的东西都必须是LLVM格式(默认情况下 ncurses 不是)。


  2. 由于输出是 JavaScript ,所以没有机会在不同的线程中执行任何程序代码。虽然很多C / C ++代码在UI和其他代码中都使用线程进行处理,但是这种模式不适用于 Emscripten 。所以为了让软件编译/运行,你必须重写使用线程的部分。对于指针,请参阅 emscripten_set_main_loop

  3. 即使您编译了库,您也必须静态将它们链接到 Emscripten 。在这一点上,它不是一个技术问题,而是更多的许可问题,因为如果你的图书馆是根据例如美国电影协会
  4. 我希望所有的清晰度最终消失;)

    I'm trying to build a project (namely, Angband's source - http://rephial.org/downloads/3.3/angband-v3.3.2.tar.gz) with Emscripten's emcc in order to port it to Javascript and ultimately build an online version.

    I've managed to get the process started with

    emconfigure ./configure make

    which begins to successfully start generating LLVM bitcode .o files, but then it hangs up on main-gcu.c with 'main-gcu.c:43:11: fatal error: 'ncurses.h' file not found'

    I believe main-gcu.c is the only file that references ncurses, but I just can't figure out how to include the library while compiling. Is there a way to specify including ncurses with 'make', or should I compile the main-gcu.c file individually, with 'emcc main-gcu.c -c -lncurses'? I tried doing that but that led to another error with emcc being unable to find other actually included header files two levels down (it couldn't find headers that were included by a header included by main-gcu.c - anyway to fix that?).

    I'm also not certain if I have/need to install the ncurses library on Mac OSX. All I can really find are references to libncurses5-dev for Linux.

    Thanks!

    解决方案

    I think you misunderstand the compilation via Emscripten. I will try to point out a few problems you are facing.

    1. The general rule is that all tools of Emscripten ONLY can turn LLVM formats (e.g. BITCODE) into JavaScript. emconfigure, emmake, ... modify the build environment so that your sourcecode is compiled to one of the LLVM formats (there are exceptions to the rule but nevermind). So anything you want to link against your final result has to be in a LLVM format, as well (which by default ncurses is not).

    2. Since the output is JavaScript, there is no chance to execute any program code in different threads. While a lot of C/C++ code does use a thread for the UI and others for processing, such a model does NOT work for Emscripten. So in order to get the software compiling/running you will have to rewrite the parts that use threading. See emscripten_set_main_loop for pointers.

    3. Even if you have the libraries compiled you then have to statically link them to Emscripten. At this point it is less of a technical problem but more of a license issue since if your library is licensed under e.g. LGPL due to static linking the GPL terms are effective.

    I hope all clarity finally vanished ;)

    这篇关于如何在使用Emscripten emcc并在Mac上制作时包含ncurses的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆