How to enable ncurses when using emccripten emcc and do on Mac

I am trying to create a project (namely, the source of Angband - http://rephial.org/downloads/3.3/angband-v3.3.2.tar.gz ) with Emscripten emcc in order to transfer it to Javascript and eventually create an online version .

I managed to start the process with

emconfigure./configure do

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

I believe main-gcu.c is the only file that references ncurses, but I just can't figure out how to enable the library at compile time. Is there a way to specify, including ncurses with "make", or do I need to compile the main-gcu.c file separately with "emcc main-gcu.c -c -lncurses"? I tried to do this, but this led to another error when emcc could not find the other actually included header files on two levels (it could not find the headers that were included by the header included by main-gcu.c - anyway to fix this?).

I'm also not sure what I need / need to install the ncurses library on Mac OSX. All I really can find are links to libncurses5-dev for Linux.

Thanks!

+4
source share
1 answer

I think you misunderstood compilation through Emscripten. I will try to point out a few problems that you are facing.

  • The general rule is that all Emscripten tools can ONLY turn LLVM formats (like BITCODE) into JavaScript. emconfigure , emmake , ... change the build environment so that the source code is compiled into one of the LLVM formats (there are exceptions to the rule, but it doesn’t matter). So, everything you want to associate with your final result should also be in LLVM format (which is not ncurses by default).

  • Since the output is JavaScript, there is no way to execute any program code in different threads. While a lot of C / C ++ code uses a stream for the user interface, and others for processing, such a model does NOT work for Emscripten. Therefore, in order to get the compilation / launch of the software, you will have to rewrite the parts that use streams. See emscripten_set_main_loop for pointers.

  • Even if you compiled libraries, you need to statically link them with Emscripten. At the moment this is less of a technical problem, but more of a problem with the license, because if your library is licensed under, for example, LGPL due to the static connection, the GPL conditions are effective.

I hope that all clarity has finally disappeared;)

+5
source

Source: https://habr.com/ru/post/1414525/


All Articles