代码之家  ›  专栏  ›  技术社区  ›  Deepflea18

Emcc编译c++文件编译不正确

  •  0
  • Deepflea18  · 技术社区  · 2 年前

    我以前有这样的:

    void extra(int x){
       printf("Here's your number: %d\n", x);
    }
    
    EXTERN EMSCRIPTEN_KEEPALIVE void myFunction(int x){
        extra(x);
    }
    

    有一个数字输入字段和一个按钮,该按钮将在按下按钮时使用输入字段中的值运行myFunction。

    此后,我将其更改为:

    // void extra(int x){
    //     printf("Here's your number: %d\n", x);
    // }
    
    EXTERN EMSCRIPTEN_KEEPALIVE void myFunction(int x){
        printf("we're done!\n");
        //extra(x);
    }
    

    然而,编译后(使用多个命令,一分钟后就会到达),按下按钮仍然只会输出“这是你的号码:[number]”

    我尝试过的命令:

    emcc hello2.cpp -s STANDALONE_WASM -o hello2.wasm
    emcc hello2.cpp -s STANDALONE_WASM
    emcc -o hello2.html hello2.cpp -O3 -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']" (this updates my html file as well, which I don't want)
    emcc -o hello2.js hello2.cpp -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']"
    
    0 回复  |  直到 2 年前