chili3d 笔记16 emscripten配置 |用cnpm i 安装 |hello world 编译

复制代码
find /usr -name Emscripten.cmake
复制代码
/usr/share/emscripten/cmake/Modules/Platform/Emscripten.cmake



复制代码
find /usr -wholename "*/emscripten/bind.h"
复制代码
/usr/share/emscripten/system/include/emscripten/bind.h
/usr/share/emscripten/cache/sysroot/include/emscripten/bind.h

上面那个文件夹缺version.h

include_directories(/usr/share/emscripten/cache/sysroot/include/)







apt的不行

复制代码
git clone https://github.com/emscripten-core/emscripten.git

/home/chen/代码/chili3d/cpp/build/emscripten/system/include




复制代码
export PATH="/home/chen/软件/emsdk:$PATH"
export EMSDK="/home/chen/软件/emsdk"
export EM_CONFIG="$EMSDK/.emscripten"
export EMSCRIPTEN="$EMSDK/upstream/emscripten"

总结,加环境变量,bootstrap一下就好了




The "workspaces" field in package.json is not supported by pnpm. Create a "pnpm-workspace.yaml" file instead.

+

用pnpm i 会这样

复制代码
npm install -g cnpm --registry=https://registry.npmmirror.com



cpp 复制代码
#include "shared.hpp"  
#include <emscripten/bind.h>  
#include <iostream>  
#include <string>  
  
using namespace emscripten;  
  
class HelloWorld {  
public:  
    static std::string sayHello() {  
        return "Hello, World from C++!";  
    }  
      
    static std::string greet(const std::string& name) {  
        return "Hello, " + name + " from C++!";  
    }  
};  
  
EMSCRIPTEN_BINDINGS(HelloWorld) {  
    class_<HelloWorld>("HelloWorld")  
        .class_function("sayHello", &HelloWorld::sayHello)  
        .class_function("greet", &HelloWorld::greet);  
}
相关推荐
大筒木老辈子4 小时前
Linux笔记---协议定制与序列化/反序列化
网络·笔记
草莓熊Lotso4 小时前
【C++】递归与迭代:两种编程范式的对比与实践
c语言·开发语言·c++·经验分享·笔记·其他
我爱挣钱我也要早睡!7 小时前
Java 复习笔记
java·开发语言·笔记
汇能感知12 小时前
摄像头模块在运动相机中的特殊应用
经验分享·笔记·科技
阿巴Jun12 小时前
【数学】线性代数知识点总结
笔记·线性代数·矩阵
茯苓gao12 小时前
STM32G4 速度环开环,电流环闭环 IF模式建模
笔记·stm32·单片机·嵌入式硬件·学习
是誰萆微了承諾12 小时前
【golang学习笔记 gin 】1.2 redis 的使用
笔记·学习·golang
DKPT13 小时前
Java内存区域与内存溢出
java·开发语言·jvm·笔记·学习
ST.J13 小时前
前端笔记2025
前端·javascript·css·vue.js·笔记
Suckerbin14 小时前
LAMPSecurity: CTF5靶场渗透
笔记·安全·web安全·网络安全