Problems building OpenCascade webGL sample

197 views
Skip to first unread message

Stefan Lang

unread,
Feb 9, 2022, 4:29:55 AM2/9/22
to emscripten-discuss
Hello

My goal is to build the OpenCascade webGL sample on Windows. Its description suggests installing and using emscripten to build the webAssembly. I've installed the latest version following the instructions, and I could build and run the provided mini examples just fine.

I am having trouble using emcmake to build FreeType and OpenCascade statically on Windows. The main issue is that emcmake insists on finding a file called
freetypeConfig.cmake or
freetype-config.cmake
But these files don't exist. And if I can resolve this, I may run into the same issue with OpenCascade which likewise doesn't provide any *config.cmake files.

cmake itself doesn't have this problem when I set freetype_DIR (as suggested on the OpenCascade Forums), but apparently emcmake ignores this.

I have already posted this at Opencascade forums, but there are already various threads on this topic, and none of the suggestions seem to have any effect when using emcmake.

I should mention that Opencascade refers to an old version of FreeType (2.5.5), but neither this nor the most current version (2.11.1) can be built using emcmake!

I have installed the latest version of emscripten, running Windows 10. I would provide more info but I have tried so many different things and changed so many parameters that I've lost track, and indeed may need to set up everything from scratch again to make sure I haven't introduced side effects. (Besides, I will eventually need to install from scratch again on the other devs' machines)

Therefore my first question to ask is: what version of emscripten should I use for Windows (and how can I query the currently installed  version?), and is there anything I specifically need to do beyond the descriptions provided on the website with regard to Windows?

Second question: I've already spotted various threads dealing with building freetype. But as far as I can tell, most if not all were related to building on Linux. Is there anything specific I need to watch out for when building FreeType on Windows?

Lastly: can I force emcmake not to search for the *config.cmake files? Alternately, is there any recommended way how to create them on Windows? In short: How can I build FreeType with emcmake on Windows when there's no *config.cmake file?

Thanks for reading this far,
Stefan

Stefan Lang

unread,
Feb 11, 2022, 7:55:57 AM2/11/22
to emscripten-discuss
As an update to my question, I'd like to add that I now found out that apparently emcmake ignores or forgets all environment variables set within the shell, unless you specifically specify them on the emcmake command line, again! Armed with this knowledge, I was able to build FreeType and then Opencascade. However, I still run into same the problem when trying to build the webGL sample: for some reason, even passing the environment variables to the FreeType dirs doesn't help. Maybe other variables are needed here, but it's impossible to figure out what is missing.

I should point out that I haven't worked with *ix and makefiles for 30 years, and although I got plenty of advice from colleagues, it's still possible I did not execute the build and install commands as expected by emscripten. If someone could post the exact commands needed to build and install a package with emscripten using the ubuntu bash shell (inside a Docker environment), that could be very helpful - maybe that would help me create the missing .cmake files?

Sam Clegg

unread,
Feb 11, 2022, 2:11:52 PM2/11/22
to emscripte...@googlegroups.com
On Fri, Feb 11, 2022 at 4:56 AM 'Stefan Lang' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
As an update to my question, I'd like to add that I now found out that apparently emcmake ignores or forgets all environment variables set within the shell, unless you specifically specify them on the emcmake command line, again! Armed with this knowledge, I was able to build FreeType and then Opencascade. However, I still run into same the problem when trying to build the webGL sample: for some reason, even passing the environment variables to the FreeType dirs doesn't help. Maybe other variables are needed here, but it's impossible to figure out what is missing.

Can you say what you mean by  "emcmake ignores or forgets all environment variables set within the shell,"?    emcmake should behave identically to cmake itself.. its really just a very small wrapper around cmake.  If you notice any differences between the way cmake honors environment variables and the way emcmake does please open bug on the issue tracker.


I should point out that I haven't worked with *ix and makefiles for 30 years, and although I got plenty of advice from colleagues, it's still possible I did not execute the build and install commands as expected by emscripten. If someone could post the exact commands needed to build and install a package with emscripten using the ubuntu bash shell (inside a Docker environment), that could be very helpful - maybe that would help me create the missing .cmake files?

Unfortunately there are many ways to build and consume libraries (and header files) so there is no one answer (e.g. pkg-config, autoconf, cmake, all do things differently).   One simple option is to create your own install directory (like a mini sysroot) where you install all your libraries and headers (via `make install` or some other method) and then you can pass `-I/path/to/my/headers` and `-L/path/to/my/libraries` to emcc.   Alternatively, you can install directly into the emscripten sysroot which lives (by default) in `<emscripten_dir>/cache/sysroot`, in which case they should be available without any extra `-I` or `-L` arguments.  Another option is to use something like `vcpkg` which has (at least some) support for emscripten already: https://vcpkg.io/en/index.html.    For what its worth, I am hoping to simplify, improve and document the situation regarding installing and consuming libraries.


On Wednesday, 9 February 2022 at 10:29:55 UTC+1 Stefan Lang wrote:
Hello

My goal is to build the OpenCascade webGL sample on Windows. Its description suggests installing and using emscripten to build the webAssembly. I've installed the latest version following the instructions, and I could build and run the provided mini examples just fine.

I am having trouble using emcmake to build FreeType and OpenCascade statically on Windows. The main issue is that emcmake insists on finding a file called
freetypeConfig.cmake or
freetype-config.cmake
But these files don't exist. And if I can resolve this, I may run into the same issue with OpenCascade which likewise doesn't provide any *config.cmake files.

cmake itself doesn't have this problem when I set freetype_DIR (as suggested on the OpenCascade Forums), but apparently emcmake ignores this.

I have already posted this at Opencascade forums, but there are already various threads on this topic, and none of the suggestions seem to have any effect when using emcmake.

I should mention that Opencascade refers to an old version of FreeType (2.5.5), but neither this nor the most current version (2.11.1) can be built using emcmake!

I have installed the latest version of emscripten, running Windows 10. I would provide more info but I have tried so many different things and changed so many parameters that I've lost track, and indeed may need to set up everything from scratch again to make sure I haven't introduced side effects. (Besides, I will eventually need to install from scratch again on the other devs' machines)

Therefore my first question to ask is: what version of emscripten should I use for Windows (and how can I query the currently installed  version?), and is there anything I specifically need to do beyond the descriptions provided on the website with regard to Windows?

Second question: I've already spotted various threads dealing with building freetype. But as far as I can tell, most if not all were related to building on Linux. Is there anything specific I need to watch out for when building FreeType on Windows?

Lastly: can I force emcmake not to search for the *config.cmake files? Alternately, is there any recommended way how to create them on Windows? In short: How can I build FreeType with emcmake on Windows when there's no *config.cmake file?

Thanks for reading this far,
Stefan

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/6155e79a-58d7-499a-826c-d9604093e465n%40googlegroups.com.

Stefan Lang

unread,
Feb 14, 2022, 3:53:26 AM2/14/22
to emscripten-discuss
Hello,

On Friday, 11 February 2022 at 20:11:52 UTC+1 ... wrote:

Can you say what you mean by  "emcmake ignores or forgets all environment variables set within the shell,"?    emcmake should behave identically to cmake itself.. its really just a very small wrapper around cmake.  If you notice any differences between the way cmake honors environment variables and the way emcmake does please open bug on the issue tracker.

For one, emcmake cmake couldn't find make, even though the command line I start emscripten from has no such difficulties: I can call cmake and make just fine. For emscripten I had to supply the full path to make it work at all. Also, I failed to use environment variables as a means to specify paths in subsequent commands; I had to specify each path literally, and directly within each emscripten command. I am not quite sure though of the exact way how emscripten accesses environment variables, how they are (supposed to be) passed on to cmake, the CMakeLists file and then make. I had hoped that emcmake cmake could take advantage of all the environment variables visible to emscripten, but apparently it doesn't work that way.
 


I should point out that I haven't worked with *ix and makefiles for 30 years, and although I got plenty of advice from colleagues, it's still possible I did not execute the build and install commands as expected by emscripten. If someone could post the exact commands needed to build and install a package with emscripten using the ubuntu bash shell (inside a Docker environment), that could be very helpful - maybe that would help me create the missing .cmake files?

Unfortunately there are many ways to build and consume libraries (and header files) so there is no one answer (e.g. pkg-config, autoconf, cmake, all do things differently).   One simple option is to create your own install directory (like a mini sysroot) where you install all your libraries and headers (via `make install` or some other method) and then you can pass `-I/path/to/my/headers` and `-L/path/to/my/libraries` to emcc.   Alternatively, you can install directly into the emscripten sysroot which lives (by default) in `<emscripten_dir>/cache/sysroot`, in which case they should be available without any extra `-I` or `-L` arguments.  Another option is to use something like `vcpkg` which has (at least some) support for emscripten already: https://vcpkg.io/en/index.html.    For what its worth, I am hoping to simplify, improve and document the situation regarding installing and consuming libraries.

While I'm not finished yet, I could at least resolve some of the trouble: it turned out that the OpenCascade documentation incorrectly points to old versions of FreeType, which either can't be built with cmake, or don't have (and don't build) the freetype-config.cmake file. Once i used a newer version I could build everything with cmake.

I'm still not sure why I couldn't build Freetype without it though: it should be possible by supplying the correct paths, but that never worked. However, it doesn't work with just cmake either, so apparently that's not related to emscripten.
Thanks for the headsup. Maybe that information will come in handy later.
Reply all
Reply to author
Forward
0 new messages