emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.98k stars 681 forks source link

emscripten seems to be not including some libs #794

Open hedwiggggg opened 3 years ago

hedwiggggg commented 3 years ago

Hey, sorry for the issue. I'm basically a newbie with emscripten, build chains and stuff. So i'm not kinda sure, if it's a problem with emscripten.

The problem is the following: I want to build libgphoto2 as wasm and made a docker container for it. libgphoto itself build's fine, by running

configure ./configure --prefix=/usr/local
make

but wrapping it in emscripten with

emconfigure ./configure --prefix=/usr/local
emmake make

will throw

checking ltdl.h usability... no
checking ltdl.h presence... no
checking for ltdl.h... no
checking that we can compile and link with libltdl... no
configure: error: cannot compile and link against libltdl
libgphoto2 requires libltdl (the libtool dl* library),
but cannot compile and link against it.
Aborting.

I debugged a bit and removed the the check in configure, but the the build will fail, because it doesn't find ltdl.h.

But adding

whereis ltdl.h
whereis libltdl

right before the failing checks in ./configure will print

ltdl: /usr/include/ltdl.h
libltdl: /usr/lib/x86_64-linux-gnu/libltdl.la /usr/lib/x86_64-linux-gnu/libltdl.so /usr/lib/x86_64-linux-gnu/libltdl.a /usr/include/libltdl

Because of this I thought this could be an issue with emscripten. Maybe someone had a similar Issue (though I have researched a lot and could not find anything) and can help me with this.

The Dockerfile I created is the following:

FROM emscripten/emsdk

RUN apt-get update
RUN apt-get install -y  automake autoconf pkg-config \
                        autopoint gettext libtool libltdl-dev libudev-dev libusb-1.0-0-dev \
                        git libcurl4-openssl-dev bison flex

WORKDIR /build
RUN git clone https://github.com/gphoto/libgphoto2.git

WORKDIR /build/libgphoto2

RUN autoreconf -fvi
RUN emconfigure ./configure --prefix=/usr/local
RUN emmake make
sbc100 commented 3 years ago

Indeed we don't include libltdl as part of emscripten. You would need to build and install that library from source if you want to use. We do include some libraries (see tools/ports) but libltdl is not one of them.

hedwiggggg commented 3 years ago

Hey @sbc100, thank you for the fast response! I'm not quite sure If I quite undestand, what you mean.

But if I understand you correctly, it would be enough to download the libltdl source, compile it and install it on the system?

sbc100 commented 3 years ago

Basically, you would need to compile it and install it somewhere that emscripten can find when you run those configure tests for it.

Ideally it would be possible to configure libgphoto2 to completely avoid the libltdl dependency, especially since emscripten support for dlopen is somewhat limited and complicated. Better to avoid dynamic linking if you can.

hedwiggggg commented 3 years ago

You mean something like Nish did it with zip in this article?