I'm new to rust and trying to create a new project using the rs_osrm = "2.0.1" crate and trunk 0.18.3, trying to apply some ideas from this tutorial.

I've installed trunk with:

cargo install --locked trunk

And following the tutorial also added the following command:

cargo install wasm-bindgen-cli

After creating the index.html and the index.scss files, when running

trunk serve

I get the following error:

2023-12-31T00:08:23.803523Z  INFO  Starting trunk 0.18.3
2023-12-31T00:08:23.827664Z  INFO  starting build
2023-12-31T00:08:23.828648Z  INFO spawning asset pipelines
2023-12-31T00:08:23.898501Z  INFO building my_map
2023-12-31T00:08:23.899002Z  INFO compiling sass/scss path="src/styles/index.scss"
2023-12-31T00:08:23.926990Z  INFO finished compiling sass/scss path="src/styles/index.scss"
   Compiling rs_osrm v2.0.1
error: failed to run custom build command for `rs_osrm v2.0.1`

Caused by:
  process didn't exit successfully: `/home/victor/Downloads/Projetos/Rust/my_map/target/debug/build/rs_osrm-8dea00b8de7dbfbf/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_wasm32-unknown-unknown = None
  CMAKE_TOOLCHAIN_FILE_wasm32_unknown_unknown = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_wasm32-unknown-unknown = None
  CMAKE_GENERATOR_wasm32_unknown_unknown = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_wasm32-unknown-unknown = None
  CMAKE_PREFIX_PATH_wasm32_unknown_unknown = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_wasm32-unknown-unknown = None
  CMAKE_wasm32_unknown_unknown = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/victor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rs_osrm-2.0.1/c_osrm" "-DCMAKE_SYSTEM_NAME=unknown" "-DCMAKE_SYSTEM_PROCESSOR=wasm32" "-DCMAKE_INSTALL_PREFIX=/home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_C_COMPILER=/usr/bin/clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_CXX_COMPILER=/usr/bin/clang" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_ASM_COMPILER=/usr/bin/clang" "-DCMAKE_BUILD_TYPE=Debug"
  -- The C compiler identification is Clang 14.0.0
  -- The CXX compiler identification is Clang 14.0.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/clang
  -- Check for working C compiler: /usr/bin/clang - broken
  -- Configuring incomplete, errors occurred!

  --- stderr
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  CMake Error at /home/victor/cmake/cmake-3.27.4-linux-x86_64/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
    The C compiler

      "/usr/bin/clang"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: '/home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out/build/CMakeFiles/CMakeScratch/TryCompile-tBLMMB'
      
      Run Build Command(s): /home/victor/cmake/cmake-3.27.4-linux-x86_64/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_7c6ea/fast
      /usr/bin/gmake  -f CMakeFiles/cmTC_7c6ea.dir/build.make CMakeFiles/cmTC_7c6ea.dir/build
      gmake[1]: Entrando no diretório '/home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out/build/CMakeFiles/CMakeScratch/TryCompile-tBLMMB'
      Building C object CMakeFiles/cmTC_7c6ea.dir/testCCompiler.c.obj
      /usr/bin/clang   -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown  -MD -MT CMakeFiles/cmTC_7c6ea.dir/testCCompiler.c.obj -MF CMakeFiles/cmTC_7c6ea.dir/testCCompiler.c.obj.d -o CMakeFiles/cmTC_7c6ea.dir/testCCompiler.c.obj -c /home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out/build/CMakeFiles/CMakeScratch/TryCompile-tBLMMB/testCCompiler.c
      Linking C executable cmTC_7c6ea
      /home/victor/cmake/cmake-3.27.4-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7c6ea.dir/link.txt --verbose=1
      /usr/bin/clang  -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown  CMakeFiles/cmTC_7c6ea.dir/testCCompiler.c.obj -o cmTC_7c6ea 
      wasm-ld-14: error: cannot open crt1.o: No such file or directory
      wasm-ld-14: error: unable to find library -lc
      wasm-ld-14: error: unable to find library -lgcc
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[1]: *** [CMakeFiles/cmTC_7c6ea.dir/build.make:100: cmTC_7c6ea] Erro 1
      gmake[1]: Saindo do diretório '/home/victor/Downloads/Projetos/Rust/my_map/target/wasm32-unknown-unknown/debug/build/rs_osrm-cc1831915fd8bd75/out/build/CMakeFiles/CMakeScratch/TryCompile-tBLMMB'
      gmake: *** [Makefile:127: cmTC_7c6ea/fast] Erro 2
      
      

    

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:2 (project)


  thread 'main' panicked at /home/victor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-12-31T00:08:24.850973Z ERROR ❌ error
error from build pipeline

Caused by:
    0: error from asset pipeline
    1: error during cargo build execution
    2: cargo call to executable 'cargo' with args: '["build", "--target=wasm32-unknown-unknown", "--manifest-path", "/home/victor/Downloads/Projetos/Rust/my_map/Cargo.toml"]' returned a bad status: exit status: 101
2023-12-31T00:08:24.852578Z  INFO  serving static assets at -> /
2023-12-31T00:08:24.852588Z  INFO  server listening at http://127.0.0.1:8080

I believe I have 32 and 64 bit versions of this crt1.o file. Command find / -name crt1.o returns (My OS is Linux Ubuntu 22.04):

/usr/libx32/crt1.o
/usr/lib32/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
/snap/octave/306/usr/lib/x86_64-linux-gnu/crt1.o
/mnt/44166ED6166EC88E/Octave-6.3.0/mingw64/lib/crt1.o

Even though the error happens when compiling rs_osrm, the crate is working fine in my already implemented code.

From the error message, it appears that I need to pass the directories to the linker wasm-ld-14, but I don't know who's calling the linker: is it rs_osrm, trunk, wasm-bindgen-cli? Is there an option for passing the directories or I would need to modify the source/scripts from one of those crates?

So, any ideas on how I could solve this?

0

There are 0 best solutions below