emcc `
    src/KinematicsWebAPI.cpp `
    src/main.cpp `
    src/Robot.cpp `
    src/RobotManager.cpp `
    src/utils.cpp `
    src/kdl_parser/src/kdl_parser.cpp `
    src/kdl_parser/src/joint.cpp `
    src/kdl_parser/src/link.cpp `
    src/kdl_parser/src/model.cpp `
    src/kdl_parser/src/pose.cpp `
    src/kdl_parser/src/tinystr.cpp `
    src/kdl_parser/src/tinyxml.cpp `
    src/kdl_parser/src/tinyxml2.cpp `
    src/kdl_parser/src/tinyxmlerror.cpp `
    src/kdl_parser/src/tinyxmlparser.cpp `
    src/kdl_parser/src/twist.cpp `
    src/kdl_parser/src/world.cpp `
    -I./inc `
    -I./src/kdl_parser/include `
    -I./KDL/install/include `
    -I./Eigen3 `
    -I./Eigen3/eigen3 `
    -L./KDL/install/lib `
    -lorocos-kdl `
    --source-map-base http://localhost:8000/ `
    -s WASM=1 `
    -s EXPORTED_FUNCTIONS='["_func","_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_malloc","_free","_main"]' `
    -s EXPORTED_RUNTIME_METHODS='["UTF8ToString","stringToUTF8","ccall","cwrap","HEAPU8", "HEAPU16", "HEAPU32", "HEAP8", "HEAP16", "HEAP32", "HEAPF32", "HEAPF64"]' `
    -s MODULARIZE=1 `
    -s EXPORT_NAME='createSmartMathModule' `
    -s ALLOW_MEMORY_GROWTH=1 `
    -s ASSERTIONS=2 `
    -s STACK_OVERFLOW_CHECK=2 `
    -s USE_PTHREADS=0 `
    -s TOTAL_MEMORY=268435456 `
    -s INITIAL_MEMORY=67108864 `
    -s MAXIMUM_MEMORY=536870912 `
    -g4 `
    -O0 `
    -o public/wasm/smart_math.js






# 方法1：使用 Chocolatey 安装 ninja
choco install ninja



# 确保你在 build_wasm 目录中
cd C:\Robotics\orocos_kinematics_dynamics\orocos_kdl\build_wasm

# 使用反引号作为续行符
emcmake cmake .. `
    -DCMAKE_INSTALL_PREFIX="C:\Robotics\kdl_wasm\KDL\install_wasm" `
    -DCMAKE_BUILD_TYPE=Release `
    -DBUILD_SHARED_LIBS=OFF `
    -DCMAKE_CXX_FLAGS="-s USE_PTHREADS=0" `
    -DCMAKE_EXE_LINKER_FLAGS="-s USE_PTHREADS=0" `
    -GNinja 
    
    

emmake ninja

cmake --install . --prefix "C:\Robotics\kdl_wasm\KDL\install_wasm"



     # 或者使用 -G "MinGW Makefiles" 如果你安装了 MinGW




    方案1：先编译 KDL 为 WebAssembly
bash
# 1. 进入 KDL 源码目录
cd /path/to/orocos-kdl

# 2. 创建构建目录并编译为 WebAssembly
mkdir build_wasm && cd build_wasm

# 3. 使用 emcmake 配置
emcmake cmake .. \
    -DCMAKE_INSTALL_PREFIX=../../kdl_wasm/KDL/install_wasm \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_CXX_FLAGS="-s USE_PTHREADS=0" \
    -DCMAKE_EXE_LINKER_FLAGS="-s USE_PTHREADS=0"

# 4. 编译和安装
emmake make -j4
emmake make install