Reputation: 67
I'd like to do emcc fibonacci.c -o fibonacci.html --emrun
but it occurs compile error.
emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.64 (a1fe3902bf73a3802eae0357d273d0e37ea79898)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
CMAKE verion3.30.2
Windows11 Pro
emcc fibonacci.c -o fibonacci.html --emrun
C:\emsdk-main\upstream\bin\llvm-objcopy.exe: error: permission denied
emcc: error: 'C:/emsdk-main/upstream/bin\llvm-objcopy.exe fibonacci.wasm fibonacci.wasm --remove-section=.debug* --remove-section=producers' failed (returned 1)
I do not understand why access to .wasm
file is denied. And it cannot output .html
file.
My code is below:
#include <stdio.h>
#include <emscripten.h>
int fibonacci(int n) {
if (n <= 1) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main(void) {
int n;
printf("Enter the position of the Fibonacci number to calculate: ");
n = emscripten_run_script_int("prompt('Enter the position of the Fibonacci number to calculate:')");
if (n < 0) {
printf("Invalid input. Please enter a positive number.\n");
return 1;
}
int result = fibonacci(n);
printf("The Fibonacci number at position %d is: %d\n", n, result);
return 0;
}
Upvotes: 1
Views: 95