Babylon React Native for Windows breaks on runtime with memory access vioaltion

Hello, I’m now trying to port @babylonjs/react-native-windows to React Native’s New Architecture.

I successfully migrated my @babylonjs/react-native-macos to New arch with very little modification and no errors, but at this time, Windows part is making some trouble.

What I did for migrating is:

  • Made a React Native new arch app named Playground and place it to ...\BabylonReactNative\Apps\Playground\0.74\
  • Modified ...\BabylonReactNative\Apps\Playground\0.74\scripts\version.js to support v0.74
  • Modified ...\BabylonReactNative\Package\gulpfile.js from Visual Studio 16 2019 to Visual Studio 17 2022
  • Modified winrt::Windows::UI::Xaml to winrt::Microsoft::UI::Xaml at several files
  • Then made a package by following Github Readme

When I copied pacakge assets generated by npx gulp packUWP to my newly created test app and ran, these error occured:

     7>BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::Initialize(class facebook::jsi::Runtime &,class std::function<void __cdecl(class std::function<void __cdecl(void)>)>)" (?Initialize@Babylon
       Native@@YAXAEAVRuntime@jsi@facebook@@V?$function@$$A6AXV?$function@$$A6AXXZ@std@@@Z@std@@@Z) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::BabylonModule::CustomInitiali
       ze(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(class facebook::jsi::Runtime &)const " (??R<lambda_1>@?1??CustomInitialize@BabylonModule@implementation@
       BabylonReactNative@winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@AEAVRuntime@jsi@facebook@@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\reac
       t-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
     7>BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::ResetView(void)" (?ResetView@BabylonNative@@YAXXZ) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::Babylon
       Module::ResetView(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(void)const " (??R<lambda_1>@?1??ResetView@BabylonModule@implementation@BabylonReactNative
       @winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@XZ) [C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\
       BabylonReactNative.vcxproj]
     7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateView(struct winrt::Microsoft::UI::Xaml::Controls::SwapChainPanel,unsigned __int64,unsigned __int64)" (?UpdateView@BabylonNative@@YAXUSwa
       pChainPanel@Controls@Xaml@UI@Microsoft@winrt@@_K1@Z) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnSizeChanged(struct winrt::Windows::Foundation::IInspectable const &,str
       uct winrt::Microsoft::UI::Xaml::SizeChangedEventArgs const &)" (?OnSizeChanged@EngineView@implementation@BabylonReactNative@winrt@@AEAAXAEBUIInspectable@Foundation@Windows@4@AEBUSizeChangedEventArgs@Xaml
       @UI@Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
     7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateMSAA(unsigned char)" (?UpdateMSAA@BabylonNative@@YAXE@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementation::EngineView::Upd
       ateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative@Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
     7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateAlphaPremultiplied(bool)" (?UpdateAlphaPremultiplied@BabylonNative@@YAX_N@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementat
       ion::EngineView::UpdateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative
       @Microsoft@4@@Z)[C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
     7>EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::RenderView(void)" (?RenderView@BabylonNative@@YAXXZ) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnRendering(
       void)" (?OnRendering@EngineView@implementation@BabylonReactNative@winrt@@AEAAXXZ) [C:\Users\jihoobyeon\Desktop\retry\node_modules\@babylonjs\react-native-windows\windows\BabylonR
       eactNative\BabylonReactNative.vcxproj]

I guess BabylonReactNative.vcxproj is unable to find ...\node_modules\@babylonjs\react-native-windows\windows\libs\*.lib,
since I have tried these workarounds:

  • Merging BabylonNative.cpp to BabylonNative.h
    → This leads to Unable to find file <Babylon/**/*.h>
  • Then writing directly #pragma comment(lib, "*.lib") to pch.h
    → This returns to LNK2019 error
  • Moving all header files manually to ...\node_modules\@babylonjs\react-native\shared\ folder
    → This leads to <napi/napi.h> or else external header not found

So I’m still finding linking *.lib files properly to the project…

ping @Cedric - who made most of recent commits for Babylon React Native

Cc @BabylonNative

Hi @jihoobyeon
I’ll take a look at this shortly.
Usually, when I get a build issue, i try to build my branch with Github Action.
Did you try to setup Github Action on your repo and use build scripts to build your branch?

Sorry for late reply. I tried running Test RN/BRN Version at Github Action and result was this:

Run npx react-native init Playground --version 0.74.5
  npx react-native init Playground --version 0.74.5
  cp Apps/Playground/playground-shared/App.tsx ./Playground/App.tsx
  cd Playground
  npx react-native-windows-init --overwrite
  npm install @babylonjs/core@6.0
  npm install @babylonjs/loaders@6.0
  npm install @babylonjs/react-native@1.5.3-preview
  npm install @babylonjs/react-native-windows-0-74@1.5.3-preview
  npm install @react-native-community/slider
  # npm install react-native-permissions
  npx react-native autolink-windows
  msbuild.exe /r "./windows/Playground.sln"
  msbuild.exe /p:Configuration="Release" /p:Platform="x64" /m "./windows/Playground.sln"
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
npm warn exec The following package was not found and will be installed: react-native@0.75.3
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm warn deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm warn deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm warn deprecated rimraf@2.6.3: Rimraf versions prior to v4 are no longer supported
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
⚠️ The `init` command is deprecated.
The behavior will be changed on 12/31/2024 (109 days).
- Switch to npx @react-native-community/cli init for the identical behavior.
- Refer to the documentation for information about alternative tools: https://reactnative.dev/docs/getting-started
Running: npx @react-native-community/cli init
- Downloading template
✔ Downloading template
- Copying template
✔ Copying template
- Processing template
✔ Processing template
- Installing dependencies
✖ Installing dependencies
error Installing pods failed. This doesn't affect project initialization and you can safely proceed. 
However, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.
- Initializing Git repository
  
  Run instructions for Android:
    • Have an Android emulator running (quickest way to get started), or a device connected.
    • cd "D:\a\BabylonReactNative\BabylonReactNative\Playground" && npx react-native run-android
  
  Run instructions for Windows:
    • See https://aka.ms/ReactNativeGuideWindows for the latest up-to-date instructions.
    
  
npm warn exec The following package was not found and will be installed: react-native-windows-init@1.4.39
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
Reading project name from package.json...
Reading react-native version from node_modules...
Cannot find module 'react-native/package.json'
Require stack:
- C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\lib-commonjs\Cli.js
- C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\bin.js
Error: Cannot find module 'react-native/package.json'
Require stack:
- C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\lib-commonjs\Cli.js
- C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
    at Function.resolve (node:internal/modules/helpers:188:19)
    at getReactNativeVersion (C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:173:33)
    at Object.reactNativeWindowsInit (C:\npm\cache\_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:563:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\npm\\cache\\_npx\\966c6a96be6f5a32\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js',
    'C:\\npm\\cache\\_npx\\966c6a96be6f5a32\\node_modules\\react-native-windows-init\\bin.js'
  ]
}
Command failed. Re-run the command with --verbose for more information.
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm warn deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated rimraf@2.6.3: Rimraf versions prior to v4 are no longer supported
npm warn deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @babel/plugin-proposal-optional-catch-binding@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
npm warn deprecated @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
npm warn deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm warn deprecated @babel/plugin-proposal-logical-assignment-operators@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
npm warn deprecated @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
npm warn deprecated @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
added 1142 packages, and audited 1143 packages in 35s
151 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
added 2 packages, and audited 1145 packages in 3s
151 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: Playground@0.0.1
npm error Found: @babylonjs/core@6.0.0
npm error node_modules/@babylonjs/core
npm error   @babylonjs/core@"6.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @babylonjs/core@"^5.42.2" from @babylonjs/react-native@1.5.3-preview
npm error node_modules/@babylonjs/react-native
npm error   @babylonjs/react-native@"1.5.3-preview" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\npm\cache\_logs\2024-09-13T12_01_11_186Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\npm\cache\_logs\2024-09-13T12_01_11_186Z-debug-0.log
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@babylonjs%2freact-native-windows-0-74 - Not found
npm error 404
npm error 404  '@babylonjs/react-native-windows-0-74@1.5.3-preview' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: C:\npm\cache\_logs\2024-09-13T12_01_13_468Z-debug-0.log
added 1 package, and audited 1146 packages in 2s
151 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
error: unknown command 'autolink-windows'
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: ./windows/Playground.sln
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: ./windows/Playground.sln
Error: Process completed with exit code 1.

You can open a PR on the main repo. Or enable Github action on your repo and open a PR on your own.

Yes, I did enabled Github Action on my forked repo.
And now I did some workarounds on Github Action .yml file and eventually I got same error with on local:

Creating library D:\a\BabylonReactNative\BabylonReactNative\Playground\windows\x64\Debug\BabylonReactNative.lib and object D:\a\BabylonReactNative\BabylonReactNative\Playground\windows\x64\Debug\BabylonReactNative.exp
BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::Initialize(class facebook::jsi::Runtime &,class std::function<void __cdecl(class std::function<void __cdecl(void)>)>)" (?Initialize@BabylonNative@@YAXAEAVRuntime@jsi@facebook@@V?$function@$$A6AXV?$function@$$A6AXXZ@std@@@Z@std@@@Z) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::BabylonModule::CustomInitialize(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(class facebook::jsi::Runtime &)const " (??R<lambda_1>@?1??CustomInitialize@BabylonModule@implementation@BabylonReactNative@winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@AEAVRuntime@jsi@facebook@@@Z) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
BabylonModule.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::ResetView(void)" (?ResetView@BabylonNative@@YAXXZ) referenced in function "public: __cdecl `public: void __cdecl winrt::BabylonReactNative::implementation::BabylonModule::ResetView(struct winrt::Microsoft::ReactNative::ReactPromise<bool> const &)'::`2'::<lambda_1>::operator()(void)const " (??R<lambda_1>@?1??ResetView@BabylonModule@implementation@BabylonReactNative@winrt@@QEAAXAEBU?$ReactPromise@_N@ReactNative@Microsoft@5@@Z@QEBA@XZ) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateView(struct winrt::Microsoft::UI::Xaml::Controls::SwapChainPanel,unsigned __int64,unsigned __int64)" (?UpdateView@BabylonNative@@YAXUSwapChainPanel@Controls@Xaml@UI@Microsoft@winrt@@_K1@Z) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnSizeChanged(struct winrt::Windows::Foundation::IInspectable const &,struct winrt::Microsoft::UI::Xaml::SizeChangedEventArgs const &)" (?OnSizeChanged@EngineView@implementation@BabylonReactNative@winrt@@AEAAXAEBUIInspectable@Foundation@Windows@4@AEBUSizeChangedEventArgs@Xaml@UI@Microsoft@4@@Z) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateMSAA(unsigned char)" (?UpdateMSAA@BabylonNative@@YAXE@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementation::EngineView::UpdateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative@Microsoft@4@@Z) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::UpdateAlphaPremultiplied(bool)" (?UpdateAlphaPremultiplied@BabylonNative@@YAX_N@Z) referenced in function "public: void __cdecl winrt::BabylonReactNative::implementation::EngineView::UpdateProperties(struct winrt::Microsoft::ReactNative::IJSValueReader const &)" (?UpdateProperties@EngineView@implementation@BabylonReactNative@winrt@@QEAAXAEBUIJSValueReader@ReactNative@Microsoft@4@@Z) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
EngineView.obj : error LNK2019: unresolved external symbol "void __cdecl BabylonNative::RenderView(void)" (?RenderView@BabylonNative@@YAXXZ) referenced in function "private: void __cdecl winrt::BabylonReactNative::implementation::EngineView::OnRendering(void)" (?OnRendering@EngineView@implementation@BabylonReactNative@winrt@@AEAAXXZ) [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
D:\a\BabylonReactNative\BabylonReactNative\Playground\windows\x64\Debug\BabylonReactNative.dll : fatal error LNK1120: 6 unresolved externals [D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj]
Done Building Project "D:\a\BabylonReactNative\BabylonReactNative\Playground\node_modules\@babylonjs\react-native-windows\windows\BabylonReactNative\BabylonReactNative.vcxproj" (default targets) -- FAILED.
Done Building Project "D:\a\BabylonReactNative\BabylonReactNative\Playground\windows\Playground\Playground.vcxproj" (GetTargetPath target(s)) -- FAILED.

Still fails to find precompiled libraries…

Can you please share a link to your repo ?

Oh, I forgot to link it. I apologize.

I see in the github action that you tried to use a 0-74 suffix. last supported suffix is 0-71 and it works with RN up to 0.74.2

Yup, so I already added 0.74 on Apps/Playground and edited Apps/Playground/scripts/version.js and Package/gulpfile.js. to support >=0.74(New arch).
Are there more files I have to modify it?

Is new arch compatible with RN versions prior to 0.74? Does new arch replace libjsi so, maybe, this abi breakage can no longer exist? Add Support for React-Native 74 and 75 · Issue #655 · BabylonJS/BabylonReactNative · GitHub

In that case, does it make sense to push new arch so we can have less different packages and we don’t have to release 2 different packages for 0.74.
cc @ryantrem

I tested and found that oldest version of react-native-windows which supports new arch is 0.73. for iOS or Android, it may be supported by older versions, but I’m not sure.

And about libjsi, when I ported BabylonReactNative to macOS at second time(to 0.74 new arch), I remember that I had to paste <V8JsiRuntime.h> to compile and get binary files.
I also found that Hermes engine still heavily relies on JSI, so it seems not to replace it.

JSI is one of the building blocks of the RN “new architecture,” but I don’t know the details, just some of the high level relationships between these different parts…

I did little more investigate, and I found that even if I directly include BabylonNative header files instead of *.lib files, it ends up with same error.
So I guess it seems to be not a flaw on binary libraries, rather it seems to be a flaw in BabylonReactNative code part.

Okay, now I managed to properly link .lib files!

error LNK2038: mismatch detected for '_COROUTINE_ABI'. value '1' doesn't match value '2' in BabylonModule.obj
error LNK2038: mismatch detected for 'C++/WinRT version'. value ''2.0.220110.5' doesn't match value '2.0.230706.1' in BabylonModule.obj

It seems to be recompile of BabylonNative is needed.

I’ve never seen the _COROUTINE_ABI issue before but it might be related to the cpp winrt mismatch.
This is a known problem. If you are building BabylonNative from the sources (Playground sample), you can make it work by changing the windows SDK version corresponding to cpp winrt version. (correct me if I’m wrong @bghgary )

-D CMAKE_SYSTEM_VERSION=10.0.19041.0 -D CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM=10.0.19041.0

This is not a long term valid solution and building a shared library instead might be the best.

Quite odd… I rebuilt all, but BabylonNative.lib did not generated, I think this isn’t a bug, since BabylonNative.cpp is in BabylonReactNative, not BabylonNative.
So I just included BabylonNative.cpp instead of BabylonNative.lib, and now error C2039: 'Something': is not a member of 'Babylon' errors are everywhere.
I tried including BabylonNative.cpp to project and adding pch.h at top of it, but it’s same.

any line number reported with the error? does it correspond to anything?

Yup, everything.
So I included header files from BabylonNative to suppress errors, now lib files links properly, but returned to LNK2038 C++/WinRT version mismatch even if I recompiled with Windows SDK 10.0.22621.0

Note that RN new arch uses Nuget package Microsoft.WindowsAppSDK instead of Microsoft.Windows.CppWinrt.

and LNK2019 still appears from two library: bimg.lib and MachineIndependentd.lib.

1>bimg.lib(image.obj) : error LNK2019: "enum astcenc_error __cdecl astcenc_config_init(enum astcenc_profile,unsigned int,unsigned int,unsigned int,float,unsigned int,struct astcenc_config *)" (?astcenc_config_init@@YA?AW4astcenc_error@@W4astcenc_profile@@IIIMIPEAUastcenc_config@@@Z)"void __cdecl bimg::imageDecodeToRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum)" (?imageDecodeToRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
1>bimg.lib(image_encode.obj) : error LNK2001: 확인할 수 없는 외부 기호 "enum astcenc_error __cdecl astcenc_config_init(enum astcenc_profile,unsigned int,unsigned int,unsigned int,float,unsigned int,struct astcenc_config *)" (?astcenc_config_init@@YA?AW4astcenc_error@@W4astcenc_profile@@IIIMIPEAUastcenc_config@@@Z)
1>bimg.lib(image.obj) : error LNK2019: "enum astcenc_error __cdecl astcenc_context_alloc(struct astcenc_config const *,unsigned int,struct astcenc_context * *)" (?astcenc_context_alloc@@YA?AW4astcenc_error@@PEBUastcenc_config@@IPEAPEAUastcenc_context@@@Z)"void __cdecl bimg::imageDecodeToRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum)" (?imageDecodeToRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
1>bimg.lib(image_encode.obj) : error LNK2001: 확인할 수 없는 외부 기호 "enum astcenc_error __cdecl astcenc_context_alloc(struct astcenc_config const *,unsigned int,struct astcenc_context * *)" (?astcenc_context_alloc@@YA?AW4astcenc_error@@PEBUastcenc_config@@IPEAPEAUastcenc_context@@@Z)
1>bimg.lib(image.obj) : error LNK2019: "enum astcenc_error __cdecl astcenc_decompress_image(struct astcenc_context *,unsigned char const *,unsigned __int64,struct astcenc_image *,struct astcenc_swizzle const *,unsigned int)" (?astcenc_decompress_image@@YA?AW4astcenc_error@@PEAUastcenc_context@@PEBE_KPEAUastcenc_image@@PEBUastcenc_swizzle@@I@Z)"void __cdecl bimg::imageDecodeToRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum)" (?imageDecodeToRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
1>bimg.lib(image.obj) : error LNK2019: "void __cdecl astcenc_context_free(struct astcenc_context *)" (?astcenc_context_free@@YAXPEAUastcenc_context@@@Z)"void __cdecl bimg::imageDecodeToRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum)" (?imageDecodeToRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
1>bimg.lib(image_encode.obj) : error LNK2001: 확인할 수 없는 외부 기호 "void __cdecl astcenc_context_free(struct astcenc_context *)" (?astcenc_context_free@@YAXPEAUastcenc_context@@@Z)
1>bimg.lib(image_encode.obj) : error LNK2019: "enum astcenc_error __cdecl astcenc_compress_image(struct astcenc_context *,struct astcenc_image *,struct astcenc_swizzle const *,unsigned char *,unsigned __int64,unsigned int)" (?astcenc_compress_image@@YA?AW4astcenc_error@@PEAUastcenc_context@@PEAUastcenc_image@@PEBUastcenc_swizzle@@PEAE_KI@Z)"void __cdecl bimg::imageEncodeFromRgba8(struct bx::AllocatorI *,void *,void const *,unsigned int,unsigned int,unsigned int,enum bimg::TextureFormat::Enum,enum bimg::Quality::Enum,class bx::Error *)" (?imageEncodeFromRgba8@bimg@@YAXPEAUAllocatorI@bx@@PEAXPEBXIIIW4Enum@TextureFormat@1@W44Quality@1@PEAVError@3@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "class TCompiler * __cdecl ConstructCompiler(enum EShLanguage,int)" (?ConstructCompiler@@YAPEAVTCompiler@@W4EShLanguage@@H@Z)ShConstructCompiler 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "class TShHandleBase * __cdecl ConstructLinker(enum EShExecutable,int)" (?ConstructLinker@@YAPEAVTShHandleBase@@W4EShExecutable@@H@Z)ShConstructLinker 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "void __cdecl DeleteLinker(class TShHandleBase *)" (?DeleteLinker@@YAXPEAVTShHandleBase@@@Z)ShDestruct 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "class TUniformMap * __cdecl ConstructUniformMap(void)" (?ConstructUniformMap@@YAPEAVTUniformMap@@XZ)ShConstructUniformMap 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "void __cdecl DeleteCompiler(class TCompiler *)" (?DeleteCompiler@@YAXPEAVTCompiler@@@Z)ShDestruct 함수에서 참조되는 확인할 수 없는 외부 기호
1>MachineIndependentd.lib(ShaderLang.obj) : error LNK2019: "void __cdecl DeleteUniformMap(class TUniformMap *)" (?DeleteUniformMap@@YAXPEAVTUniformMap@@@Z)ShDestruct 함수에서 참조되는 확인할 수 없는 외부 기호

(Sorry for Korean error message; these are quite long to translate)