Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Assembly problems #107

Open
paulocoutinhox opened this issue Feb 4, 2022 · 19 comments
Open

Web Assembly problems #107

paulocoutinhox opened this issue Feb 4, 2022 · 19 comments

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented Feb 4, 2022

Hi,

I found this problems when compile to WASM:

1 - This line throw error that GLFW_SCALE_TO_MONITOR don't exists (screen.cpp):

glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

2 - This method glfwSetWindowContentScaleCallback throw error that don't exists (screen.cpp):

glfwSetWindowContentScaleCallback(m_glfw_window,
        [](GLFWwindow* w, float, float) {
            auto it = __nanogui_screens.find(w);
            if (it == __nanogui_screens.end())
                return;
            Screen* s = it->second;

            s->m_pixel_ratio = get_pixel_ratio(w);
            s->resize_callback_event(s->m_size.x(), s->m_size.y());
        }
    );

3 - Adding a fixed suffix .bc don't work on emsdk:

[ 83%] Linking CXX static library libnanogui.bc
em++: warning: object file output extension (.bc) used for non-object output.  If you meant to build an object file please use `-c, `-r`, or `-shared` [-Wemcc]
wasm-ld: error: unknown file type: _deps/nanogui-build/libnanogui.bc

em++: error: '/Users/paulo/.conan/data/emsdk/3.1.0/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/bin/wasm-ld -o bin/nativium.wasm CMakeFiles/nativium.dir/modules/app-core/implementation/cpp/nativium/core/ApplicationCoreImpl.cpp.o CMakeFiles/nativium.dir/modules/app-core/gluecode/generated-src/wasm/nativium/core/NTVCoreApplicationCore.cpp.o CMakeFiles/nativium.dir/modules/support-lib/djinni/cpp/DataRef.cpp.o CMakeFiles/nativium.dir/modules/support-lib/djinni/wasm/DataRef_wasm.cpp.o CMakeFiles/nativium.dir/modules/support-lib/djinni/wasm/djinni_wasm.cpp.o _deps/nanogui-build/libnanogui.bc -L/Users/paulo/.conan/data/emsdk/3.1.0/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/.emscripten_cache/sysroot/lib/wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL -lal -lhtml5 -lstubs-debug -lc-debug -lcompiler_rt -lc++ -lc++abi -lemmalloc -lc_rt -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=malloc --export=free --export=__cxa_is_pointer_type --export=__cxa_can_catch --export=setThrew --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024' failed (returned 1)
make[2]: *** [bin/nativium.js] Error 1
@paulocoutinhox
Copy link
Author

paulocoutinhox commented Feb 4, 2022

I made a PR to fix all and all is working nice now.
#108

You can use this example to download nanogui with CPM (cmake package manager):

# cpm
include(get_cpm.cmake)

# nanogui
set(NANOGUI_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(NANOGUI_BUILD_PYTHON  OFF CACHE BOOL " " FORCE)
set(NANOGUI_INSTALL       OFF CACHE BOOL " " FORCE)
set(NANOGUI_BUILD_SHARED  OFF CACHE BOOL " " FORCE)
set(NANOGUI_BUILD_GLFW    OFF CACHE BOOL " " FORCE)
set(NANOGUI_BACKEND       "GLES 3" CACHE STRING " " FORCE)

CPMAddPackage(
    NAME
    nanogui
    GIT_TAG
    wasm-fix
    GITHUB_REPOSITORY
    paulo-coutinho/nanogui
)

# add nanogui as project library
list(APPEND NATIVIUM_LIBRARY_LINKS "nanogui")

# add nano gui include as search path
nativium_add_search_path("${nanogui_SOURCE_DIR}/include")

And at least:

# wasm
set_target_properties(MY_PROJECT_NAME PROPERTIES LINK_FLAGS "-s EXPORTED_RUNTIME_METHODS=['ccall','cwrap'] --bind -s MALLOC=emmalloc -s WASM_BIGINT=1 -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1")

@paulocoutinhox
Copy link
Author

@mischievous
Copy link

mischievous commented Jul 13, 2022

DEAD ... Found a better way... See next comment.

After much pain I was able to get this to build on OSX also...

  1. You have to correct an issue with emscripten
    a. Open your version of emcc.py
    b. Find the run function ... "def run (args):"
    c Add these lines to the very top of the run function... Because of clang being installed these args are being passed to the emcc (em++) compilers and they don't don't how to handle them as of version 3.14. This just removes the illegal args.
    for argv in [ '-Wl,-search_paths_first', '-Wl,-headerpad_max_install_names' ]:
    if argv in args:
      args.remove (argv)
d. Hard part is done. 
  1. Go into the nanogui directory.
  2. Create a new directory called "web", or something appropriate; then cd to the directory.
  3. cmake .. -DCMAKE_CXX_COMPILER=em++ -DCMAKE_C_COMPILER=emcc -Wno-dev
  4. make
  5. python3 -m http.server
  6. In a webbrowser - http://127.0.0.1:8000/example1.html

@mischievous
Copy link

Follow the instructions from this page... (summarized)
https://emscripten.org/docs/getting_started/downloads.html

  1. git clone https://github.com/emscripten-core/emsdk.git
  2. cd emsdk
  3. git pull
  4. ./emsdk install latest (3.1.34)
  5. ./emsdk activate latest
  6. source <path_to_emsdk_env.sh>

Checkout nanogui

  1. cd nanogui
  2. vi CMakelists.txt
    a. change set(CMAKE_EXECUTABLE_SUFFIX ".bc") -> set(CMAKE_EXECUTABLE_SUFFIX ".html") :: (optional, but I could not figure out how to run with out an *.html file)
    b. change set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -o <LINK_FLAGS> ") -> set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -r -o <LINK_FLAGS> ") :: Will no produce a static library without it.
    c. add add_compile_options(-Wno-unused-command-line-argument) :: removes some warnings.
  3. mkdir web
  4. cd web
  5. CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make
  6. python3 -m http.server

@deloverzeus
Copy link

Follow the instructions from this page... (summarized) https://emscripten.org/docs/getting_started/downloads.html

  1. git clone https://github.com/emscripten-core/emsdk.git
  2. cd emsdk
  3. git pull
  4. ./emsdk install latest (3.1.34)
  5. ./emsdk activate latest
  6. source <path_to_emsdk_env.sh>

Checkout nanogui

  1. cd nanogui
  2. vi CMakelists.txt
    a. change set(CMAKE_EXECUTABLE_SUFFIX ".bc") -> set(CMAKE_EXECUTABLE_SUFFIX ".html") :: (optional, but I could not figure out how to run with out an *.html file)
    b. change set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -o <LINK_FLAGS> ") -> set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -r -o <LINK_FLAGS> ") :: Will no produce a static library without it.
    c. add add_compile_options(-Wno-unused-command-line-argument) :: removes some warnings.
  3. mkdir web
  4. cd web
  5. CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make
  6. python3 -m http.server

occur some errors,
overzeus@gxf188 web]$ emmake make
make: make
[ 2%] Running bin2c
[ 4%] Building C object CMakeFiles/nanogui.dir/ext/nanovg/src/nanovg.c.o
clang: error: unsupported option '-march=' for target 'wasm32-unknown-emscripten'
make[2]: *** [CMakeFiles/nanogui.dir/build.make:95:CMakeFiles/nanogui.dir/ext/nanovg/src/nanovg.c.o] error 1
make[1]: *** [CMakeFiles/Makefile2:93:CMakeFiles/nanogui.dir/all] error 2
make: *** [Makefile:136:all] error 2
emmake: error: 'make' failed (returned 2)

@mischievous
Copy link

Do you have the correct version 3.1.34? The error sounds like you are trying to build on a mac and the "-march" is causing problems which the emsdk does not care about. My cmake building foo is not strong enough to know how to remove the "-march".

@deloverzeus
Copy link

Do you have the correct version 3.1.34? The error sounds like you are trying to build on a mac and the "-march" is causing problems which the emsdk does not care about. My cmake building foo is not strong enough to know how to remove the "-march".

I build on windows(MingW64)

@deloverzeus
Copy link

Do you have the correct version 3.1.34? The error sounds like you are trying to build on a mac and the "-march" is causing problems which the emsdk does not care about. My cmake building foo is not strong enough to know how to remove the "-march".

My emsdk version 3.1.54. I remove "-march" .I use your instructions "set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -r -o <LINK_FLAGS> ")" but the new error is :
"em++: error: option '-o' requires an argument
make[2]: *** [CMakeFiles/nanogui.dir/build.make:679:libnanogui.bc] error 1
make[1]: *** [CMakeFiles/Makefile2:93:CMakeFiles/nanogui.dir/all] error 2
make: *** [Makefile:136:all] error 2"

@mischievous
Copy link

Once emsdk is installed I think you and do a "emsdk install 3.1.34" and then "emsdk activate 3.1.34", or something like that. I would give that a try first then if it does not work move forward.

@mikamyara
Copy link

Hello,
I have problems with nanoGui on Webassembly on fresh linux/Debian 12 install (in a dedicated VM). This is my first experience with webassembly as well as with nanogui, however I know well C/C++ and gui dev.
I suceeded in installing and using nanoGui with native intel C/C++ on my main Linux machine. Well.
Debian 12 proposes a package with 3.1.6 and I did not succeed in installing nanoGui. So I created a VM with still Debian 12 (but no GUI) to avoid breaking my install. In installed emsdk from sources, and what comes is 3.1.56. To follow what is previously suggested, I tried to downgrade to 3.1.34 with "emsdk install 3.1.34" and here is what comes :

emsdk install 3.1.34
Resolving SDK version '3.1.34' to 'sdk-releases-2fdd6b9e5b67d5b62f84d0501a876513ff118ef1-64bit'
Installing SDK 'sdk-releases-2fdd6b9e5b67d5b62f84d0501a876513ff118ef1-64bit'..
Skipped installing node-16.20.0-64bit, already installed.
Installing tool 'releases-2fdd6b9e5b67d5b62f84d0501a876513ff118ef1-64bit'..
Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/2fdd6b9e5b67d5b62f84d0501a876513ff118ef1/wasm-binaries.tar.xz': HTTP Error 404: Not Found
Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/2fdd6b9e5b67d5b62f84d0501a876513ff118ef1/wasm-binaries.tbz2': [Errno 13] Permission denied: '/home/mmyara/emsdk/downloads/2fdd6b9e5b67d5b62f84d0501a876513ff118ef1-wasm-binaries.tbz2'
Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/2fdd6b9e5b67d5b62f84d0501a876513ff118ef1/wasm-binaries.tar.xz': HTTP Error 404: Not Found
error: installation failed!

So I continued with 3.1.56. So I git the nanogui :

git clone https://github.com/wjakob/nanogui.git --recursive

I think since the post the nanogui has changed as I did not find any "march" for example in the CMakeLists.txt

then followed as proposed above with :

cd nanogui
mkdir web
cd web
CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make

and here follows what I get :

configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/mmyara/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/home/mmyara/emsdk/node/16.20.0_64bit/bin/node
CMake Deprecation Warning at ext/glfw/CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Using X11 for window creation
CMake Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.25/Modules/FindX11.cmake:481 (find_package_handle_standard_args)
  ext/glfw/CMakeLists.txt:190 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/mmyara/nanogui/nanogui/web/CMakeFiles/CMakeOutput.log".
emcmake: error: 'cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/mmyara/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/home/mmyara/emsdk/node/16.20.0_64bit/bin/node' failed (returned 1)
make: make
make: *** Pas de cible spécifiée et aucun makefile n'a été trouvé. Arrêt.
emmake: error: 'make' failed (returned 2)

So it does not work. I tried to install X11 related dev libraries as it is the problem expressed : " sudo apt-get install cmake xorg-dev libglu1-mesa-dev", no more success. Can someone help ?

regards,
Mike

@mischievous
Copy link

Last time I touched the code was on 2023/03/15... Can you try the commit hash from before that date?

@mikamyara
Copy link

Here it is :

git rev-parse --verify HEAD
e9ec8a1a9861cf578d9c6e85a6420080aa715c03

@mikamyara
Copy link

I think I did not clone the good "nanogui" project. I try now with "mitsuba-render". Sorry. I will give news after try.

@mikamyara
Copy link

mikamyara commented Mar 25, 2024

It is better this time but does not still work. I think the library builds ok, but not the examples.
I did mainly what mischievous said :

a. change set(CMAKE_EXECUTABLE_SUFFIX ".bc") -> set(CMAKE_EXECUTABLE_SUFFIX ".html") :: (optional, but I could not figure out how to run with out an *.html file)
b. change set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -o <LINK_FLAGS> ") -> set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -r -o <LINK_FLAGS> ") :: Will no produce a static library without it.
c. add add_compile_options(-Wno-unused-command-line-argument) :: removes some warnings.

also removed the "march" lines (79-91)

Then

mkdir web
cd web
CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make

and here is what I get :

[ 78%] Linking CXX static library libnanogui.bc
[ 78%] Built target nanogui
[ 80%] Building CXX object CMakeFiles/example1.dir/src/example1.cpp.o
[ 82%] Linking CXX executable example1.html
libnanogui.bc:1:2: error: expected top-level entity
    1 | <U+0000>asm<U+0001><U+0000><U+0000><U+0000><U+0001><B8><U+0005>N`<U+0003><U+007F><U+007F><U+007F><U+0000>`<U+0003><U+007F><U+007F><U+007F><U+0001><U+007F>`<U+0001><U+007F><U+0000>`<U+0005><U+007F><U+007F><U+007F><U+007F><U+007F><U+0000>`<U+0005><U+007F><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F>`<U+0006><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0000>`<U+0001><U+007F><U+0001><U+007F>`<U+0002><U+007F><U+007F><U+0000>`<U+0006><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F>`<U+0002><U+007F><U+007F><U+0001><U+007F>`<U+0004><U+007F>}}}<U+0000>`<U+0004><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F>`<U+0007><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0001><U+007F>`<U+0008><U+007F><U+007F><U+007F><U+007F>}<U+007F><U+007F><U+007F><U+0000>`<U+0008><U+007F><U+007F><U+007F><U+007F>}}<U+007F><U+007F><U+0000>`<U+0004><U+007F><U+007F><U+007F><U+007F><U+0000>`<U+0001>}<U+0001>}`<U+0002>||<U+0001>|`<U+0002>}}<U+0001>}`<U+0002>|<U+007F><U+0001>|`        <U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0000>`<U+0000><U+0001><U+007F>`<U+0007><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+007F><U+0000>`<U+0002><U+007F>}<U+0000>`<U+0003><U+007F>}}<U+0000>`<U+0005><U+007F>}}}}<U+0000>`<U+0001>}<U+0000>`<U+0004>}}}}<U+0000>`<U+0001>|<U+0000>`<U+0000><U+0000>`<U+0000><U+0001>|`<U+0003><U+007F>||<U+0001><U+007F>`<U+0002><U+007F>}<U+0001>}`
      |         ^
1 error generated.
em++: error: '/home/mmyara/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/mmyara/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O3 -DNDEBUG libnanogui.bc -c -o /tmp/emscripten_temp_hcg5y5ht/libnanogui_0.o' failed (returned 1)
make[2]: *** [CMakeFiles/example1.dir/build.make:101 : example1.html] Erreur 1
make[1]: *** [CMakeFiles/Makefile2:119 : CMakeFiles/example1.dir/all] Erreur 2
make: *** [Makefile:136 : all] Erreur 2
emmake: error: 'make' failed (returned 2)

@mischievous
Copy link

As soon as I can scratch my head I will check the git hash I have and re-try with my instructions.

@mischievous
Copy link

mischievous commented Mar 26, 2024

emsdk list

The recommended precompiled SDK download is 3.1.48 (694434b6d47c5f6eff2c8fbd9eeb016c977ae9dc).

To install/activate it use:
latest

This is equivalent to installing/activating:
3.1.48

All recent (non-legacy) installable versions are:
3.1.48
3.1.48-asserts
3.1.47
3.1.47-asserts
....
3.1.35
3.1.35-asserts
3.1.34 INSTALLED
3.1.34-asserts
3.1.33

CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make
configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/local/Cellar/emsdk/node/16.20.0_64bit/bin/node
-- NanoGUI v0.2.0
-- Setting build type to 'Release' as none was specified.
-- NanoGUI: using GLES 2 backend.
-- NanoGUI: building static library.
-- NanoGUI: not building the Python plugin.
-- Configuring done (1.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Volumes/Promise/projects/runeQuest/nanogui/web
make: make
[ 2%] Running bin2c
CMake Deprecation Warning at /Volumes/Promise/projects/runeQuest/nanogui/resources/bin2c.cmake:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

[ 4%] Building C object CMakeFiles/nanogui.dir/ext/nanovg/src/nanovg.c.o
[ 6%] Building CXX object CMakeFiles/nanogui.dir/src/texture_gl.cpp.o
[ 8%] Building CXX object CMakeFiles/nanogui.dir/src/shader_gl.cpp.o
[ 10%] Building CXX object CMakeFiles/nanogui.dir/src/renderpass_gl.cpp.o
[ 13%] Building CXX object CMakeFiles/nanogui.dir/src/opengl.cpp.o
[ 15%] Building CXX object CMakeFiles/nanogui.dir/nanogui_resources.cpp.o
[ 17%] Building CXX object CMakeFiles/nanogui.dir/src/common.cpp.o
[ 19%] Building CXX object CMakeFiles/nanogui.dir/src/widget.cpp.o
[ 21%] Building CXX object CMakeFiles/nanogui.dir/src/theme.cpp.o
[ 23%] Building CXX object CMakeFiles/nanogui.dir/src/layout.cpp.o
[ 26%] Building CXX object CMakeFiles/nanogui.dir/src/screen.cpp.o
[ 28%] Building CXX object CMakeFiles/nanogui.dir/src/label.cpp.o
[ 30%] Building CXX object CMakeFiles/nanogui.dir/src/window.cpp.o
[ 32%] Building CXX object CMakeFiles/nanogui.dir/src/popup.cpp.o
[ 34%] Building CXX object CMakeFiles/nanogui.dir/src/checkbox.cpp.o
[ 36%] Building CXX object CMakeFiles/nanogui.dir/src/button.cpp.o
[ 39%] Building CXX object CMakeFiles/nanogui.dir/src/popupbutton.cpp.o
[ 41%] Building CXX object CMakeFiles/nanogui.dir/src/combobox.cpp.o
[ 43%] Building CXX object CMakeFiles/nanogui.dir/src/progressbar.cpp.o
[ 45%] Building CXX object CMakeFiles/nanogui.dir/src/slider.cpp.o
[ 47%] Building CXX object CMakeFiles/nanogui.dir/src/messagedialog.cpp.o
[ 50%] Building CXX object CMakeFiles/nanogui.dir/src/textbox.cpp.o
[ 52%] Building CXX object CMakeFiles/nanogui.dir/src/textarea.cpp.o
[ 54%] Building CXX object CMakeFiles/nanogui.dir/src/imagepanel.cpp.o
[ 56%] Building CXX object CMakeFiles/nanogui.dir/src/vscrollpanel.cpp.o
[ 58%] Building CXX object CMakeFiles/nanogui.dir/src/colorwheel.cpp.o
[ 60%] Building CXX object CMakeFiles/nanogui.dir/src/colorpicker.cpp.o
[ 63%] Building CXX object CMakeFiles/nanogui.dir/src/graph.cpp.o
[ 65%] Building CXX object CMakeFiles/nanogui.dir/src/tabwidget.cpp.o
[ 67%] Building CXX object CMakeFiles/nanogui.dir/src/canvas.cpp.o
[ 69%] Building CXX object CMakeFiles/nanogui.dir/src/texture.cpp.o
[ 71%] Building CXX object CMakeFiles/nanogui.dir/src/shader.cpp.o
[ 73%] Building CXX object CMakeFiles/nanogui.dir/src/imageview.cpp.o
[ 76%] Building CXX object CMakeFiles/nanogui.dir/src/traits.cpp.o
[ 78%] Linking CXX static library libnanogui.bc
[ 78%] Built target nanogui
[ 80%] Building CXX object CMakeFiles/example1.dir/src/example1.cpp.o
[ 82%] Linking CXX executable example1.html
[ 82%] Built target example1
[ 84%] Building CXX object CMakeFiles/example2.dir/src/example2.cpp.o
[ 86%] Linking CXX executable example2.html
[ 86%] Built target example2
[ 89%] Building CXX object CMakeFiles/example3.dir/src/example3.cpp.o
[ 91%] Linking CXX executable example3.html
[ 91%] Built target example3
[ 93%] Building CXX object CMakeFiles/example4.dir/src/example4.cpp.o
[ 95%] Linking CXX executable example4.html
[ 95%] Built target example4
[ 97%] Building CXX object CMakeFiles/example_icons.dir/src/example_icons.cpp.o
[100%] Linking CXX executable example_icons.html
[100%] Built target example_icons

@mischievous
Copy link

git hash...
git rev-parse HEAD
2ee903c

@mischievous
Copy link

If you are getting failures in the 3 files below I can do a diff and see what I changed but I think the only change was in CMakeLists.txt

git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: CMakeLists.txt
modified: include/nanogui/textbox.h
modified: src/screen.cpp
modified: src/textbox.cpp

@mikamyara
Copy link

Hello,
Thanks to your help I suceeded in compiling everything !
Just something was wrong : emcc "latest" is NOT 3.1.48, it is 3.1.56, and with 3.1.56 it does not work at link time, did not understand why.
Here is what I did :

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.48
./emsdk activate 3.1.48
source ./emsdk_env.sh

cd ..
git clone https://github.com/mitsuba-renderer/nanogui.git --recursive
cd nanogui

For other users : please notice that at this time the last commit is 8 March 2023 (2ee903c).

Then had to change the CMakeLists.txt including points a,b and c, as discussed before in this thread. I enclose a CMakeLists.txt file ready to work with this message, so that other users only have to copy it :
CMakeLists.txt

Then :

mkdir web
cd web
CXXFLAGS='-s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1' emcmake cmake ..; emmake make

Then start a python webserver to test :

python3 -m http.server

Then everything is ok. Thanks a lot ! I will be able now to start my project.

Just a remark, don't know if it's normal, but, in webassembly context :

  • example3 does not work,
  • example_icons does only displays a gray background rectangle.

Best Regards,
Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants