wasm-ld error: unknown file type: libgmp.a wasm-ld:error: undefined symbol: __gmpz_clear
I want to build https://github.com/Iwctwbh/Factorial-BenchMark in wasm. Can you tell me the correct steps?
wasm-ld error: unknown file type: libgmp.a wasm-ld:error: undefined symbol: __gmpz_clear
I want to build https://github.com/Iwctwbh/Factorial-BenchMark in wasm. Can you tell me the correct steps?
Below are my steps
GMP
./configure
make
make check
make install
Then, I get .lib/libgmp.a
main.cpp
#include <iostream>
#include <gmpxx.h>
int fibonacci(int n) {
if (n <= 0) return 0;
if (n == 1) return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
mpz_class result = 1;
int n = 10;
std::cout << "Fibonacci(" << n << ") = " << fibonacci(n) << std::endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(FibonacciProject)
# Enable Emscripten
set(CMAKE_TOOLCHAIN_FILE D:\\emsdk\\emsdk\\upstream\\emscripten\\cmake\\Modules\\Platform\\Emscripten.cmake)
# Set the output format to WebAssembly (wasm)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
# Add the source file to the project
add_executable(FibonacciProject main.cpp)
add_library(gmp STATIC IMPORTED)
set_target_properties(gmp PROPERTIES IMPORTED_LOCATION D://gmp//.libs//libgmp.a)
target_include_directories(FibonacciProject PRIVATE D:\\gmp)
target_link_libraries(FibonacciProject gmp)
Then, I try emcmake cmake .. emmake make
I tried it in Windows11/Linux/Docker, but it always gives an error and is not the same. Please help me.