1

I want to compile SealPIR library using emscripten to generate a wasm file. When using this command: emcmake cmake .

I get this error:

CMake Error at CMakeLists.txt:19 (find_package):
  By not providing "FindSEAL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SEAL", but
  CMake did not find one.

  Could not find a package configuration file provided by "SEAL" (requested
  version 3.2.0) with any of the following names:

    SEALConfig.cmake
    seal-config.cmake

  Add the installation prefix of "SEAL" to CMAKE_PREFIX_PATH or set
  "SEAL_DIR" to a directory containing one of the above files.  If "SEAL"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/Zied/webassembly/SealPIR/CMakeFiles/CMakeOutput.log".
emcmake: error: 'cmake . -DCMAKE_TOOLCHAIN_FILE=/home/Zied/webassembly/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/home/Zied/webassembly/emsdk/node/14.15.5_64bit/bin/node"' failed (1)  

SEAL is correctly installed. when i run the same command without emcmake it works just fine. This is my CMakeList

cmake_minimum_required(VERSION 3.10)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(SealPIR VERSION 2.1 LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

add_executable(main 
    main.cpp
)

add_library(sealpir STATIC
  pir.cpp
  pir_client.cpp
  pir_server.cpp
)

find_package(SEAL 3.2.0 EXACT REQUIRED)

target_link_libraries(main sealpir SEAL::seal)
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
Zied
  • 11
  • 1
  • 3
  • `SEAL is correctly installed.` Did you also compiled it with emscripten? Where did you installed it? Can you locate the `SEALConfig.cmake` file and put the path here? – Guillaume Racicot Jun 16 '21 at 14:50
  • @GuillaumeRacicot Yes, I compiled it using emscripten and generated a libseal.a and a wasm file for it. I can also locate the SEALConfig.cmake but I have no idea how to link it to SealPIR. – Zied Jun 16 '21 at 14:55
  • "I can also locate the SEALConfig.cmake but I have no idea how to link it to SealPIR." - Isn't the error message explains that? You could set `SEAL_DIR` environment variable to contain a directory with given script. – Tsyvarev Jun 16 '21 at 15:04
  • Well i did so , `export SEAL_DIR=/home/Zied/webassembly/SEAL/native/src/cmake ` I also tried `emcmake cmake . -CMAKE_PREFIX_PATH=/home/Zied/webassembly/SEAL/native/src/cmake/` but i always have the same problem – Zied Jun 16 '21 at 15:10
  • @Zied Please. What is the full path of the `SEALConfig.cmake` file? – Guillaume Racicot Jun 16 '21 at 15:23
  • You set the prefix path in the wrong place but I need the full path to help you. – Guillaume Racicot Jun 16 '21 at 15:24
  • @Zied Hmm, that's not the right one. Where did you installed the library? The one CMake will read is the file in the installation directory only. – Guillaume Racicot Jun 16 '21 at 15:38
  • I think this is the one `/usr/local/lib/cmake/SEAL` – Zied Jun 16 '21 at 15:46

1 Answers1

1

When using a toolchain file for cross compiling, CMake will by default disable system libraries. It won't search into any directory to avoid finding files that is not compatible with the target system.

You think you didn't used a toolchain file? Think again! emcmake hides that from you. Look carefully at the error output.

Here you compiled the SEAL library, but you installed it in the default path, which is /usr/local.

We can tell CMake to explicitly search there, but I wouldn't recommend, but you can try if it works:

emcmake cmake . -CMAKE_PREFIX_PATH=/usr/local

The proper solution would be to create a directory with all the emscripten libraries in it:

# In the SEAL build directory
emcmake cmake .. -DCMAKE_INSTALL_PREFIX=/home/anblic/webassembly/install

Then after installing the libraries in that directory, you can set the prefix path in the same directory as the install path:

# Assuming you're in a build/ subdirectory
emcmake cmake .. -DCMAKE_PREFIX_PATH=/home/anblic/webassembly/install
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
  • When i run `emcmake cmake . -CMAKE_PREFIX_PATH=/usr/local/lib/cmake/SEAL` it's still not working, i m getting this error `CMake Error: Error processing file: /app/SealPIR/MAKE_PREFIX_PATH=/usr/local/lib/cmake/SEAL` . I m pretty sure it's the right path because when i run cmake instead it locates SEAL here `//The directory containing a CMake configuration file for SEAL. SEAL_DIR:PATH=/usr/local/lib/cmake/SEAL`. In addition CMakeOurput.log contains `The target system is: Emscripten - 1 - x86 The host system is: Linux - 5.4.0-74-generic - x86_64` – Zied Jun 21 '21 at 09:45
  • @Zied You must set the prefix path as the same as the installation prefix, not the directory containing the config file. `find_package` will then use the prefix and look for `lib/cmake/SEAL/SEALConfig.cmake` from the prefix path. That way, you can put all your libraries in the same prefix and instruct CMake to find all libraries there. – Guillaume Racicot Jun 21 '21 at 13:54
  • This is why I wrote that you must use `/usr/local` as the prefix path, and why in the two following examples I had put the same path in the two prefixes. – Guillaume Racicot Jun 21 '21 at 13:56