0

I've been trying to build Qhull for use on the net, and to be honest. I'm completely lost. I've already installed the Emscripten SDK, and I've tried reading through the guides. From what I can gather, it seems that there are two ways to compile a large project like this one: I can either pass the files as arguments to emcc, or I can make my own custom Makefile that somehow does that for me. But I can neither figure out how to pass multiple files as arguments, nor how Makefiles work.

After scouring the web, I managed to find this port of an old Qhull version, which comes with its own Makefile:

QHULL_PATH = ./src/libqhull
TARGET = qhull.js
EMCC = ../emscripten/emcc
PREJS = ./src/pre.js
POSTJS = ./src/post.js
MAIN = ./src/main.c
EXPORTJS = "['_run_qhull']"
CFLAGS = -O1

SOURCES := $(shell find $(QHULL_PATH) -type f -name '*.c')

all: $(TARGET)
    @echo  "Done"

$(TARGET): $(SOURCES) $(PREJS) $(POSTJS) $(MAIN)
    $(EMCC) $(CFLAGS) $(SOURCES) $(MAIN) -s EXPORTED_FUNCTIONS=$(EXPORTJS) --pre-js $(PREJS) --post-js $(POSTJS) -o $(TARGET)

clean:
    rm -rf $(TARGET)

Unfortunately, the Makefile is in the Unix format, which I only figured out after about two hours of frustration. I don't know how to make it work on Windows.

So, what can I do to get the latest version of Qhull running in Javascript?

I'm using Windows, and my current IDE is Dev-C++.

ViHdzP
  • 107
  • 7

1 Answers1

1

So if you're new to compiling, using emscripten to compile a large library is going to be a big challenge. I suggest reading through the emscripten docs on compiling.

It looks like Qhull has both a MakeFile and a CMakeLists.txt. I suggest trying CMake.
The typical way to use CMake with emscripten on linux is something like this:

mkdir embuild
cd embuild
emcmake cmake ..
emmake make

I've never compiled on Windows (I use linux), but I believe that (at least when using Cmake) it is similar.
That probably won't work on the first try.
If (after many tries) you can't get it working, you could try compiling qhull manually with emcc. It looks harder at first, but in the long run I usually get fewer errors.

cajomar
  • 428
  • 5
  • 9