建造大型Wasm的或工具

发布于 2025-01-25 04:30:59 字数 2215 浏览 2 评论 0原文

我正在开发一个依赖Google Or-Tools依靠的一部分的Glazor WASM工具,并通过利用andaberfilereference在.NET 6 Blazor WASM中遇到问题。

我在应用程序中使用相同方法在应用程序中使用了其他C ++库,并且它们在没有hiccup 请参阅史蒂夫·桑德森(Steve Sanderson)谈话。但是,Or-Tools具有很多依赖性,并且在结构上更为复杂。

我的目标是将我可以在项目中使用和运送的单个二进制文件编译,我将编写一个C ++条目文件,其中包含我需要与C#进行交互的所有功能,如下面的第2号尝试。另请参见静态链接部分

我尝试了什么? :

  1. 我看了看 sudoku solver ,他在文章中提到他必须迭代依赖关系,直到他获得了wasm构建并创建了补丁,我不确定它是如何实现的。但是我认为我可以将Suduko示例添加到用于测试的空的Blazor WASM项目中,更改emcc命令,使用- 共享-s-s生成单个bindary WASM = 1并删除任何JavaScript使用。但是我在链接emscripten:错误:emscript:emscript:未能从wasm-emscripten farmine-finalize中解析元数据输出,这似乎是 this dotnet doc ,如果我通过了> > sudokus.cc文件我在标题上找不到文件错误。

  2. 我转到此问题将示例用作从构建WASM的起点,然后以相同的方式使用main.cpp,但在大风中使用。那也没有用。

我的问题:

a。从Or-Tools构建WASM单二进制的正确方法是什么?
b。第2号尝试实际上可以工作吗?如果是这样,那么构建它的构建还需要的是WASM。

谢谢你!

系统信息:
Ubuntu 21.10
GCC/G ++ 11.2.0
dotnet 6.0.202
Emscripten 3.1.9

I am developing a Blazor wasm tool that relies on Google OR-Tools for some part and im running into problems building the library and using it in .NET 6 Blazor wasm by leveraging NativeFileReference.

I have been using other C++ Libraries in my application using the same approach and they build and integrate without a hiccup see Steve Sanderson Talk. but the OR-Tools has a lot of dependencies and is way more complex in structure.

my goal is to compile to a single binary which I can use and ship in my projects, where I'll write a C++ entry file that contains all the functions I need to interact with C# as in attempt no.2 below.see also Static linking section

what have I tried ? :

  1. I took a look at the Sudoku Solver, he mentions in the article that he had to iterate over the dependencies until he got a wasm build and created patches, which I'm unsure how it was achieved. but I figured I can add the suduko example to an empty Blazor wasm project for testing, changing the emcc command to generate a single bindary using - shared and -s WASM=1 and removing any Javascript use. but I got a Json parse error on linking emscripten : error : emscript: failure to parse metadata output from wasm-emscripten-finalize which appears to be a version mismatch error according to this and the dotnet doc, if I pass the sudokus.cc file I get a file not found error on headers.

  2. I referred to this question and tried to use the example as a starting point to build wasm from and simply use the main.cpp in the same fashion but in Blazor. that also didn't quite work.

my questions:

a. What is the correct way to build a wasm single binary from OR-Tools (regardless of the size) ?
b. would attempt no.2 actually work ? if so, what is additionally required to build it as is but for wasm.

Thank you!

System Information:
Ubuntu 21.10
gcc/g++ 11.2.0
dotnet 6.0.202
Emscripten 3.1.9

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鯉魚旗 2025-02-01 04:30:59

我将在此处留给其他任何希望使用Or-Tools用于Glazor Wasm的人,请注意,此答案是针对问题B。的原始问题。

如果您希望通过“或工具”中的特定工具执行某个作业,则在保持大发应用程序的上下文中,此方法很有用。请注意,这使用了非常古老的Or-Tools(暂时)。

  1. install/downgrade emscripten v2.0.23(.net wasm-tools中使用的当前版本)
  2. clone kjartanm/wasm-or-tools
  3. 遵循有关此叉子的下的构建步骤
  4. 在输入C ++文件上的EMCC命令上进行调整以产生单个二进制文件

emcc -o3
- 绑定
-lm
-s lld_report_undefined
-s error_on_undefined_symbols = 0
-s exported_functions ='[“ method_in_entry_file”]'
-i wasmbuild/install/包括
-lwasmbuild/install/lib
-lglog
-labsl_bad_any_cast_impl
-labsl_log_severity
-labsl_bad_optional_access


列表太长编辑命令中的示例构建shell脚本
/name_of_entry_file.cc
-shared -o输出/路径/output_name.o

  1. 在您的Blazor应用中包含.o文件。 a>

I'll leave this here for anyone else looking to use or-tools for Blazor wasm, please note that this answer is meant for question b. in original question.

In the context of keeping the Blazor App light this method is useful if you want a certain job to be executed by a specific tool in or-tools. mind you that this uses a very old version of or-tools (for the time being).

  1. install/downgrade Emscripten v2.0.23 (current version used in .NET wasm-tools)
  2. Clone kjartanm/wasm-or-tools
  3. Follow build steps under About this fork
  4. do adjustments on emcc command on entry C++ file to produce a single binary

emcc -O3
--bind
-lm
-s LLD_REPORT_UNDEFINED
-s ERROR_ON_UNDEFINED_SYMBOLS=0
-s EXPORTED_FUNCTIONS='["method_in_entry_file"]'
-I wasmbuild/install/include
-Lwasmbuild/install/lib
-lglog
-labsl_bad_any_cast_impl
-labsl_log_severity
-labsl_bad_optional_access
.
.
. list too long edit the command in example build shell script
/name_of_entry_file.cc
-shared -o output/path/output_name.o

  1. Include the .o file in your blazor app. see here for details
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文