Open FantasyDev-ux opened 1 year ago
Hey, just a few questions to help troubleshoot this:
Thanks for your answer.
I tried to compile this library with this command : cargo build
###########################################################################################
Compiling lsl-sys v0.1.1 (E:\Work\assignment\liblsl-rust\lsl-sys)
error: failed to run custom build command for lsl-sys v0.1.1 (E:\Work\assignment\liblsl-rust\lsl-sys)
Caused by:
process didn't exit successfully: E:\Work\assignment\liblsl-rust\target\debug\build\lsl-sys-a5acfb16c103d45e\build-script-build
(exit code: 101)
--- stdout
CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-msvc = None
CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_msvc = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_x86_64-pc-windows-msvc = None
CMAKE_GENERATOR_x86_64_pc_windows_msvc = None
HOST_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_x86_64-pc-windows-msvc = None
CMAKE_PREFIX_PATH_x86_64_pc_windows_msvc = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_x86_64-pc-windows-msvc = None
CMAKE_x86_64_pc_windows_msvc = None
HOST_CMAKE = None
CMAKE = None
running: "cmake" "E:\Work\assignment\liblsl-rust\lsl-sys\liblsl" "-G" "Visual Studio 17 2022" "-Thost=x64" "-Ax64" "-DLSL_NO_FANCY_LIBNAME=ON" "-DLSL_BUILD_STATIC=ON" "-DWIN32=1" "-D_WINDOWS=1" "-DCMAKE_C_FLAGS= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS= /nologo /EHsc /MD /GR" "-DCMAKE_C_FLAGS_DEBUG= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS_DEBUG= /nologo /EHsc /MD /GR" "-DCMAKE_C_FLAGS_RELEASE= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS_RELEASE= /nologo /EHsc /MD /GR" "-DCMAKE_INSTALL_PREFIX=E:\Work\assignment\liblsl-rust\target\debug\build\lsl-sys-e12c5892ce9988ad\out" "-DCMAKE_ASM_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS_DEBUG= -nologo -MD -Brepro" "-DCMAKE_BUILD_TYPE=Debug"
--- stderr CMake Warning: Ignoring extra path from command line:
"E:\Work\assignment\liblsl-rust\lsl-sys\liblsl"
CMake Error: The source directory "E:/Work/assignment/liblsl-rust/lsl-sys/liblsl" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. thread 'main' panicked at ' command did not execute successfully, got: exit code: 1
build script failed, must exit now', C:\Users\Administrator.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.50\src\lib.rs:1098:5
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
###########################################################################################
So I tried to compile the LSL library on my system, first. I download https://github.com/sccn/liblsl and compile it on my system. using 2 command: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="build/install" cmake --build build -j --config Release --target install I can see the compiled result : lsl.lib, lsl.dll, and header files.
Then I copied all files in folder liblsl to E:\Work\assignment\liblsl-rust\lsl-sys\liblsl
I will send you some blocks of log:
Compiling hackeeg-client-rust v0.1.0 (E:\Work\assignment\hackeeg-client-rust_git)
error: could not find native static library lsl-static
, perhaps an -L flag is missing?
warning: lsl-sys
(lib) generated 7 warnings
The following warnings were emitted during compilation:
warning: couldn't execute llvm-config --prefix
(error: program not found)
warning: set the LLVM_CONFIG_PATH environment variable to a valid llvm-config
executable
error: could not compile lsl-sys
due to previous error; 7 warnings emitted
warning: build failed, waiting for other jobs to finish...
warning: unused import: lsl_sys
--> src\client\mod.rs:16:5
|
16 | use lsl_sys;
I'm wanting to your kind answer.
Best regards.
Edited by cboulay: I hope you don't mind but I fixed the order of the 2 cmake commands you used for liblsl. Though I'm pretty sure you used them in this corrected order, I'm fixing it for future readers.
Ok I think the root cause of your issue is probably that you may have forgotten the --recurse-submodules argument when you git cloned the liblsl-rust repo. That's because liblsl is a git submodule, and when you're not cloning it recursively, the liblsl folder will be empty or absent. Then cargo will complain that there's no CMakeLists.txt in there. So you'll want to retry the initial git clone and retry the cargo build
.
The liblsl-rust repo is locked to a specific version (commit id) of upstream liblsl with which it has been tested -- so that's another reason why you'd want to try going through regular cargo instead of manually compiling the static lib (e.g., the libname may have been refactored since then, plus the build script takes the library dir (the -L) from the result of successfully compiling the dependency.
Thanks for your kind answer.
I did, you told me.
But I have some compile errors:
PS E:\Work\assignment\liblsl-rust-recur> cargo build
Updating crates.io index
Compiling cc v1.0.79
Compiling cmake v0.1.50
Compiling lsl-sys v0.1.1 (E:\Work\assignment\liblsl-rust-recur\lsl-sys)
error: failed to run custom build command for lsl-sys v0.1.1 (E:\Work\assignment\liblsl-rust-recur\lsl-sys)
Caused by:
process didn't exit successfully: E:\Work\assignment\liblsl-rust-recur\target\debug\build\lsl-sys-a5acfb16c103d45e\build-script-build
(exit code: 101)
--- stdout
CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-msvc = None
CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_msvc = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
process didn't exit successfully: E:\Work\assignment\liblsl-rust-recur\target\debug\build\lsl-sys-a5acfb16c103d45e\build-script-build
(exit code: 101)
--- stdout
CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-msvc = None
CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_msvc = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_x86_64-pc-windows-msvc = None
CMAKE_GENERATOR_x86_64_pc_windows_msvc = None
HOST_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_x86_64-pc-windows-msvc = None
CMAKE_PREFIX_PATH_x86_64_pc_windows_msvc = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_x86_64-pc-windows-msvc = None
CMAKE_x86_64_pc_windows_msvc = None
HOST_CMAKE = None
CMAKE = None
running: "cmake" "E:\Work\assignment\liblsl-rust-recur\lsl-sys\liblsl" "-G" "Visual Studio 17 2022" "-Thost=x64" "-Ax64" "-DLSL_NO_FANCY_LIBNAME=ON" "-DLSL_BUILD_STATIC=ON" "-DWIN32=1" "-D_WINDOWS=1" "-DCMAKE_C_FLAGS= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS= /nologo /EHsc /MD /GR" "-DCMAKE_C_FLAGS_DEBUG= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS_DEBUG= /nologo /EHsc /MD /GR" "-DCMAKE_C_FLAGS_RELEASE= /nologo /EHsc /MD /GR" "-DCMAKE_CXX_FLAGS_RELEASE= /nologo /EHsc /MD /GR" "-DCMAKE_INSTALL_PREFIX=E:\Work\assignment\liblsl-rust-recur\target\debug\build\lsl-sys-e12c5892ce9988ad\out" "-DCMAKE_ASM_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS_DEBUG= -nologo -MD -Brepro" "-DCMAKE_BUILD_TYPE=Debug"
-- Configuring incomplete, errors occurred!
See also "E:/Work/assignment/liblsl-rust-recur/target/debug/build/lsl-sys-e12c5892ce9988ad/out/build/CMakeFiles/CMakeOutput.log".
--- stderr CMake Error at CMakeLists.txt:2 (project): Generator
Visual Studio 17 2022
could not find any instance of Visual Studio.
thread 'main' panicked at ' command did not execute successfully, got: exit code: 1
build script failed, must exit now', C:\Users\Administrator.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.50\src\lib.rs:1098:5
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
PS E:\Work\assignment\liblsl-rust-recur>
I have already installed Visual studio 2019. How can I change this option "Visual Stiod 17 2022" to "Visual Studio 16 2019" ?
Please help me. Thanks.
Hi, it looks like you'll have to install that version of VS as well side-by-side with the other to be able to compile that version of liblsl. It's pretty common with VS that a specific version is required by a given program. Probably because they're not mutually ABI-compatible (when compiling C++ code).
Thanks, bro. But I have a question. lsllib or lsl-sys are already compiled by others and I can add it to project by command: cargo add lsl or cargo add lsl-sys.
Then why do I have to compile lsllib (C library) every time?
I want to know these two questions.
Can't we meet through Skype or Slack?
To answer your q's:
Can't I use is with command cargo add lsl?
Yes, all you need to do is add lsl
to your Cargo.toml file, and then cargo will try to fetch and build the sources for you behind the scenes. It may still need the right system C/C++ compiler installed depending on the OS. You do not need to clone this repo (that's just for users who want to contribute to the crate etc). It might be a bit confusing in the way the sections are ordered in the readme.
Why do I have to compile lsllib every time?
It's been a while since I worked on this package, but that just happens to be how the lsl-sys crate is set up currently (it would have to maintain a large amount of trusted prebuilt binaries for the targeted liblsl versions and OSes, so that causes quite some overhead and friction when wanting to upgrade to the next version). Since in the rust ecosystem everyone is juggling a compiler and (often) wrapped native libraries anyway, it seemed like an acceptable cost. I don't have much time on the side besides my day job at this time (which also answers your latest question I hope). However, the good news is that, for a given project you'll only need to compile this once and then you're settled since it'll be cached.
What is difference between lsl and lsl-sys?
You can find that explained in the readme at the bottom: lsl-sys
is a thin wrapper around the raw system library and requires unsafe {}
clauses to use, while lsl
is a memory-safe high-level wrapper that follows rust conventions. It's a pretty common way in the rust world to expose system libraries in 2 levels. There's also a link to all the API docs in case you need them.
Dear everyone.
I downloaded this project and tried to compile on Windows 10. But I have some concerns. There is one error: error: could not find native static library
lsl-static
, perhaps an -L flag is missing?Can you kindly help me with this error?