WebGL sample compilation

Hi

Im trying to build. WebGL sample.

I managed to build FreeType and OCCT libraries using emsdk, but I cant build sample itself.

While configuring this sample in Cmake-gui I have error message. (both windows ans linux)

CMake Error at CMakeLists.txt:33 (find_package):
Could not find a package configuration file provided by "freetype" with any
of the following names:

freetypeConfig.cmake
freetype-config.cmake

Add the installation prefix of "freetype" to CMAKE_PREFIX_PATH or set
"freetype_DIR" to a directory containing one of the above files. If
"freetype" provides a separate development package or SDK, be sure it has
been installed.

 

Setting freetype_DIR to freetype installation path does not work. Adding installation path to CMAKE_PREFIX_PATH has no effect. Simply I don't have freetypeConfig.cmake freetype-config.cmake files there

Any sugestions?

Regards

Adam

Kirill Gavrilov's picture

If you've built FreeType without using CMake, then you have to extend CMake scripts for WebGL sample with FreeType search paths (similar to "adm/cmake/freetype.cmake" used for building OCCT itself).
Alterantively, you can re-build FreeType using CMake - in this case FreeType installation folder will have "lib/cmake/freetype/freetype-config.cmake" configuration file, so that freetype_DIR in WebGL sample should point to this "lib/cmake/freetype" folder.

Adam Wnek's picture

Thank you for reply,

Actually I have edited CMakeLists.txt in webgl sample to fit my local paths where emscirpten complied libraries have been installed. I just finished and it works. :)  Now I have some basic understanding how it works, and I can try prepare my own small WebAssembly application

Regards

Adam

Andy Du's picture

Hi Kirill,
My case is "If you've built FreeType without using CMake, then you have to extend CMake scripts for WebGL sample with FreeType search paths (similar to "adm/cmake/freetype.cmake" used for building OCCT itself).",
I tried to add the free path into CmakeLists.txt of WebGL sample, but not success.
The line I added is, I use the absolute path:
set(freetype "C:/OpenCASCADE-7.5.0-vc14-64/opencascade-7.5.0/adm/cmake/freetype.cmake")
Do you have any suggestions?

Thanks,
Andy

Paul BIGEON's picture

Hi

Another issue regarding the compilation that I've had, using :

OCCT 7.6.0 dev
Emscripten 1.39.7 ( MinGW 4.6.2-32bit )

Compiling seems ok, but when it comes to linking :

Anyone found a way to get through this one ?

Thanks,

Paul

Kirill Gavrilov's picture

Is there some reason for using an old Emscripten 1.x branch instead of Emscripten 2.x (opened since August '2020)?
And where MinGW 4.6.2-32bit comes from? I see only mingw-7.1.0-64bit in Emscripten SDK.

Don't recall "unknown suffix" error, so cannot help here...

Paul BIGEON's picture

Hi and thank you for your reply,

I'm using my already existing Emscripten environment based on the Qt for WebAssembly requirements.
This might be the issue now that you point that out ...

I'll give it a try with updated Emscripten and MinGW.

Regards,

Paul

Paul BIGEON's picture

Hi and thanks for your prompt reply,

I did use the Qt 5.15.2 for WebAssembly tutorial and the recommended version for Emscripten is 1.39.7 ...

I Installed and activated Emscripten 2.0.23 and mingw-7.1.0-64bit as you indicated, and now the process goes a bit further, yet it splashes this new error :

A bit of search on the github issues indicates that it could be linked to newest version of Emscripten not handling things the same as they used to in previous releases.

I'll have a go at different versions and see which one can fit then ...

Regards,

Paul

Kirill Gavrilov's picture

My guess is that you are trying now to build the Sample without clean rebuild of OCCT libraries...

I haven't updated Emscripten for a while, so my currently installed version is older - it is 2.0.11. But I hope that they haven't broken something with newer updates (apart from useless deprecation that can be seen in your log)...

Paul BIGEON's picture

It worked with 2.0.11, I did not rebuilt OCCT ...

Well the sample is built and linked correctly now.

Thanks for your help as always !

Regards

Paul

Vrainy Z's picture

Hi

I have another issue about the compilation.

Using:

  • OCCT 7.6.0
  • cmake version 3.22.1
  • emsdk 2.0.11

Command:

     emcmake cmake .. -DOpenCASCADE_DIR=E:\package\opencascade\opencascade-install\cmake -G "Visual Studio 16 2019" -A x64

Error:

CMakeOutput.log:

 The target system is: Emscripten - 1 - x86_64
The host system is: Windows - 10.0.19043 - AMD64

Edited files

webgl/CMakeLists.txt

# FreeType
set(freetype_DIR E:/package/thrid-part/freetype-2.5.5)
# find_package(freetype REQUIRED NO_DEFAULT_PATH)
# if(freetype_FOUND)
#   message (STATUS "Using FreeType from \"${freetype_DIR}\"" )
# else()
#   message(WARNING "Could not find FreeType, please set freetype_DIR variable." )
# endif()

# Open CASCADE Technology
find_package(OpenCASCADE REQUIRED)

 Emscripten.cmake

# Advertise Emscripten as a 32-bit platform (as opposed to
# CMAKE_SYSTEM_PROCESSOR=x86_64 for 64-bit platform), since some projects (e.g.
# OpenCV) use this to detect bitness.

# set(CMAKE_SYSTEM_PROCESSOR x86)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

I found a similar error. link.

You are trying to build a x86 (32bit) program saying that you want to link it to a 64bit library. Then the mess.
Just check the script that you are using to trigger the build, there lies the problem :)

I edited "set(CMAKE_SYSTEM_PROCESSOR x86)" to "set(CMAKE_SYSTEM_PROCESSOR x86_64)" in Emscripten.cmake, but it didn't work.

Anyone found a way to get through this one ?

Thanks,

Vrainy

Kirill Gavrilov's picture

     emcmake cmake .. -DOpenCASCADE_DIR=E:\package\opencascade\opencascade-install\cmake -G "Visual Studio 16 2019" -A x64

I never heard about CMake supporting generation of Visual Studio project files crosscompiling using Emscripten SDK. Anyhow, "-A x64" looks broken in options, as WASM64 doesn't yet exist, browsers support only 32-bit WASM32. Don't know how this architecture should be called when specified to CMake though, since this is not x86.

Vrainy Z's picture

Thanks a lot. I compiled successfully using mingw-7.1.0-64bit in emsdk list.

By the way, i never used cmake before, it confused me for a long time.
But it got easier when i figured out how to use cmake-gui with emsdk.

Thanks again for your reply.

Regards,
Vrainy