pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
606 stars 91 forks source link

Could NOT find X11 ( missing: X11_X11_LIB) when building web app(emscripten) #24

Closed JaosnHsieh closed 1 year ago

JaosnHsieh commented 1 year ago

Updated

I'm now able to build emscripten on this project imgui_manual and it works on browser. Although below errors haven't solved but I should be able to figure it out what went wrong below by looking into imgui_manual.

Original

Thanks for the awesome project !

I was able to build linux desktop app in _example_integration but failed to build the web app(emscripten). If someone can guide me through this would be really appreciative! I use docker for quickly get the development environment and it works for linux desktop app well.

The failed part is in the Build web app(emscripten) below.

Build pthom/hello_imgui.git

requirements

Docker version 20.10.7, build f0df350

Steps

$ docker run --rm -it --user 0 -p 5901:5901 -p 6901:6901 consol/debian-xfce-vnc

open browser and navigate to http://localhost:6901/?password=vncpassword

open Terminal app and install tools

apt update && apt install -y git build-essential cmake`
apt install libglfw3-dev libxinerama-dev libxcursor-dev libxi-dev libx11-dev

Download pthom/hello_imgui.git

cd ~
git clone https://github.com/pthom/hello_imgui.git

Build linux desktop app and run

cd ~/hello_imgui/
cd _example_integration
mkdir build && cd build
cmake .. && make hello_world .. && ./hello_world

Yayyy~~ I can see hello world application running in the linux now

Install emscripten

~/hello_imgui/tools/emscripten/install_emscripten.sh
source ~/emsdk/emsdk_env.sh

Build web app(emscripten)


cd ~/hello_imgui/src/hello_imgui_demos/_example_integration

mkdir build_emscripten && cd build_emscripten

emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON ..

./_deps/hello_imgui-src/tools/sdl_download.sh

emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON .. #again

After emcmake cmake .. -DHELLOIMGUI_USE_SDL_OPENGL3=ON ...

the Error shows Could NOT find X11 as below

Screenshot 2022-12-08 at 5 08 03 pm

pthom commented 1 year ago

Hi,

Thanks for your message.

I just pushed some corrections: basically the _example_integration should not download sdl nor glfw when using emscripten, and should force the use of SDL (which is already provided by emscripten).

If you update, and browse to the new _example_integration, you will see that the instructions are now:

(cd _example_integrationbefore this!)

# Add emscripten tools to your path
source ~/emsdk/emsdk_env.sh

# cmake and build
mkdir build_emscripten
cd build_emscripten
emcmake cmake ..
make -j 4

# launch a webserver
python3 -m http.server

Please keep me informed about the status!