我想用 emscripten 构建香蕉面包 c++ 项目。
我添加了 BINARYEN_ROOT 介绍 ./emscripten 。
我还构建了 BINARYEN。
LLVM_ROOT = '/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/fastcomp/bin'
EMSCRIPTEN_ROOT = '/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/fastcomp/emscripten'
EMSCRIPTEN_NATIVE_OPTIMIZER = '/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/fastcomp/bin/optimizer'
NODE_JS = '/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/node/12.9.1_64bit/bin/node'
BINARYEN_ROOT = '/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/binaryen/tag-1.38.31'
错误日志:
致命:必须设置 initialStackPointer 共享:错误:'/Volumes/POMOCNI/WWW-HTDOCS/emsdk-demos/emsdk/emsdk/binaryen/tag-1.38.31/bin/wasm-emscripten-finalize /var/folders/hf/ (pk7l6fn14pj6qft1ns016bqh0000gn/T/emscripten_temp_oiJjbb/tmpDk949v.wasm -o /var/folders/hf/pk7l6fn14pj6qft1ns016bqh0000gn/T/emscripten_temp_oiJjbb/tmpDk949v.wasm.o.wasm24'base-features 失败)编译失败!make: *** [客户端] 错误 1
我的 src 是单个文件:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <GLFW/glfw3.h>
GLFWwindow *window;
// Include GLM
#include "glm.hpp"
using namespace glm;
int main(void)
{
// Initialise GLFW
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
getchar();
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
window = glfwCreateWindow(1024, 768, "Tutorial 01", NULL, NULL);
if (window == NULL)
{
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
getchar();
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
if (glewInit() != GLEW_OK)
{
fprintf(stderr, "Failed to initialize GLEW\n");
getchar();
glfwTerminate();
return -1;
}
// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
// Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
do
{
// Clear the screen. It's not mentioned before Tutorial 02, but it can cause flickering, so it's there nonetheless.
glClear(GL_COLOR_BUFFER_BIT);
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
} // Check if the ESC key was pressed or the window was closed
while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0);
// Close OpenGL window and terminate GLFW
glfwTerminate();
return 0;
}
我的生成文件:
LDFLAGS=-O1 --llvm-opts 2 test: mkdir -p build emcc tutorial01.cpp \ -s USE_GLFW=3 \ $(SDLFLAGS) \ -lGL \ -I/Volumes/POMOCNI/WWW-HTDOCS/cpp/openglTutorials/ogl/external/glm-0.9.7.1/glm \ -std=c++14 \ -o web/test.html \ -g