Build library with windows and double precision #276
Closed
daxur-studios
started this conversation in
Ideas
Replies: 1 comment
-
closing as duplicate, found discussion here: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, it took me a couple of days to get this working and didn't find any example, so thought I'd share in case anyone else wants to build the lib in a windows machine with double precision enabled.
build.ps1
Also updated
CMakeLists.txt
to improve cross-platform compatibility and streamline the build process.I've put together a readme about my findings to build with windows here:
Building JoltPhysics.js
This document provides comprehensive instructions for building JoltPhysics.js from source, including Windows-specific setup and troubleshooting.
Prerequisites
Required Tools
Emscripten SDK (emsdk)
CMake (3.13 or higher)
Python 3
Ninja Build System
Git
Windows-Specific Setup
On Windows, additional setup is required:
1. Install Visual Studio Build Tools
Install Visual Studio 2022 with:
2. Install Dependencies via Chocolatey (Recommended)
3. Environment Variables
Add to your PATH:
C:\Program Files\CMake\bin
C:\Python39\
(or your Python installation path)C:\Program Files\Git\bin
Quick Start (Windows)
Using the Bundled emsdk
Activate Emscripten:
Set up environment and build:
Manual emsdk Installation
Download and install emsdk:
Build the library:
# In the JoltPhysics.js root directory .\emsdk\emsdk_env.ps1 .\build.ps1
Build Process Details
What Gets Built
The build process creates multiple variants:
Single-threaded builds:
jolt-physics.wasm-compat.js
- WASM with embedded binaryjolt-physics.wasm.js
- WASM with separate binary filejolt-physics.js
- asm.js versionMulti-threaded builds:
jolt-physics.multithread.wasm-compat.js
jolt-physics.multithread.wasm.js
Debug builds:
jolt-physics.debug.wasm-compat.js
jolt-physics.debug.multithread.wasm-compat.js
TypeScript definitions:
types.d.ts
- Main type definitions.d.ts
files for each variantBuild Configuration Options
You can customize the build by passing options to the build scripts:
Linux/macOS Build
Windows-Specific Fixes Applied
The build system includes several Windows compatibility fixes:
1. CMake Command Fixes
cat
with${CMAKE_COMMAND} -E cat
for cross-platform file concatenationsed
commands to use CMake's cross-platform alternatives2. PowerShell Variable Expansion
Fixed variable expansion issues in
build.ps1
:3. Environment Variable Quoting
Fixed environment variable handling for multi-threaded builds:
Troubleshooting
Common Issues
1. "emcc: command not found"
Solution: Ensure emsdk environment is activated:
2. "cmake: no compatible generator found"
Solution: Install Ninja build system:
3. "Python command not found"
Solution: Ensure Python is in PATH or use full path:
4. Build Fails with "sed: command not found"
Solution: This is handled automatically by the Windows build fixes, but ensure you're using the provided build scripts.
5. Memory Issues During Build
Solution: Increase Node.js memory limit:
Debug Builds
For debugging C++ code in the browser:
jolt-physics.debug.*.js
)Performance Optimization
-DBUILD_WASM_COMPAT_ONLY=ON
for faster builds during development-DENABLE_SIMD=ON
for better performance (limited browser support)Package Creation
After building, create an npm package:
Development Workflow
.\build.ps1
npm run examples
npm pack
Examples
See the
Examples/
directory for usage examples:falling_shapes.html
- Basic physics simulationproper_cleanup.html
- Memory management examplecharacter_virtual_controller.html
- Character controller demoContributing
When contributing to the build system:
Related Documentation
Beta Was this translation helpful? Give feedback.
All reactions