Can't install cargo-tree: couldn't determine visual studio generator - windows

I'm trying to install cargo-tree on my Windows machine. It uses Windows 10, Visual Studio build tools 15. This is my active rustup toolchain:
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.26.0 (a77568041 2018-05-07)
When running cargo install cargo-tree, the build fails. The build log ends with:
error: failed to run custom build command for `libssh2-sys v0.2.7`
process didn't exit successfully: `C:\Users\NICOLA~1\AppData\Local\Temp\cargo-installt7F5FM\release\build\libssh2-sys-726b9e90a2ed2b95\build-script-build` (exit code: 101)
--- stderr
fatal: not a git repository (or any of the parent directories): .git
thread 'main' panicked at '
couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
', C:\Users\nicolas-delsaux\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.31\src\lib.rs:552:25
note: Run with `RUST_BACKTRACE=1` for a backtrace.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-tree v0.18.0`, intermediate artifacts can be found at `C:\Users\NICOLA~1\AppData\Local\Temp\cargo-installt7F5FM`
According to some documentation I found on the web, it seems to be related to some vcvars script to invoke, and an older Visual Studio version to install. I don't fully understand what to do so
Should I install an older version of Visual Studio?
Do I have some script to run?

According to #user25064, this requires installing the command through developer command prompt (and, more specifically, the developer command prompt for your architecture - take attention to x86/x64 architectures)

Related

Use vcpkg on WSL 1 with Visual Studio

I'm adventuring myself into compiling a CMake project using Visual Studio, targeting WSL 1.
Following Microsoft's tutorial to setup a CMake project in Visual Studio and debugging on WSL works fine. Things break when I try to install and use packages using Microsoft's vcpkg package manager after installing vcpkg into a separate Windows directory and integrating it into Visual Studio.
A simple example that fails:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test)
find_package(protobuf CONFIG REQUIRED)
with the following error message:
CMake Error at C:\test\CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by
"protobuf" with any of the following names
protobufConfig.cmake
protobuf-config.cmake
Add the installation prefix of "unofficial-sqlite3" to CMAKE_PREFIX_PATH or
set "protobuf_DIR" to a directory containing one of the above
files. If "protobuf" provides a separate development package or
SDK, be sure it has been installed.
I'm getting Intellisense to recognize find_package and suggesting to install the package or copying the vcpkg command to clipboard.
The CMake toolchain file is pointing to the "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" file in the WSL-GCC-Debug configuration settings. Installing vcpkg on the Linux system and setting the CMake toolchain file to the corresponding path creates the exact same error output.
Running the "vcpkg install protobuf:x64-linux" command in the terminal creates the following output:
Computing installation plan...
The following packages will be built and installed:
protobuf[core]:x64-linux -> 3.14.0#1
Detecting compiler hash for triplet x64-linux...
Error: while detecting compiler information:
The log content at C:\vcpkg\buildtrees\detect_compiler\stdout-x64-linux.log is:
-- Configuring x64-linux
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:108 (message):
Command failed: ninja -v
Working Directory: C:/vcpkg/buildtrees/detect_compiler/x64-linux-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\vcpkg\buildtrees\detect_compiler\config-x64-linux-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:319 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:128 (include)
Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
This is not a surprise as I don't expect it to be able to build packages targeting Linux on my Windows machine.
I'm new to cross-platform development and I find documentation on vcpkg + WSL rather sparse. Am I right in assuming that the packages should be installed by vcpkg running on the Linux system? Or do I need to have CMake setup on Windows to make vcpkg work on the Windows side?
Setup:
Windows 10 Build 19041
Visual Studio 2019 (16.8.5) with Visual C++ for Linux Development
Ubuntu 20.04 LTS as WSL
vcpkg commit f226416d2
It seems that I was a bit off track.
vcpkg installed on the Windows machine is accessible on the Linux system the same way as the actual CMake project is accessible. Setting the "CMAKE_TOOLCHAIN_FILE" variable to the absolute "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" path gets translated into "/mnt/c/vcpkg/scripts/buildsystems/vcpkg.cmake".
The missing step was to run the ./bootstrap-vcpkg.sh script on the Linux system to make sure packages can be installed by vcpkg on the Linux system.
I also learned that packages have to be installed manually by running the vcpkg install command since there is no "build in" way to do this via CMake.

I want to verify that Rust compiler can call Visual Studio C++ Build tool properly with some simple code example

New question: Could some one please give me some trivial code example to verify that Rust compiler can call Visual Studio C++ Build tool properly?
Original question:
I followed the instruction on the page of Rust site:
You may need to install the Visual Studio C++ Build tools
After finishing installation of the C build tools, though I failed to build a crate(Nannou) with the following error message:
VS code:
> cargo run --release --example draw
...
...
Compiling examples v0.1.0 (O:\OneDrive\Git\IT\download\Rust\nannou-master\examples)
Finished release [optimized] target(s) in 7m 00s
Running `target\release\examples\draw.exe`
thread 'main' panicked at 'could not build default app window: NoAvailableAdapter', O:\OneDrive\Git\IT\download\Rust\nannou-master\nannou\src\app.rs:457:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\release\examples\draw.exe` (exit code: 101)
I found that the path environment variable has not added for the installed C build tools. And I can't find where the C build tools are installed on my windows.
Please help me to setup the c build tools for Rust properly.
Nannou crate

couldn't determine visual studio generator

I am trying to compile rust's azul gui framework sample code on windows 10 and it's running into the following error:
error: failed to run custom build command for `harfbuzz-sys v0.3.0 (https://github.com/maps4print/azul-dependencies?rev=bf2933b9aac43a7003278862772250398e4fa457#bf2933b9)`
Caused by:
process didn't exit successfully: `F:\Code\rust\azul_demo\target\debug\build\harfbuzz-sys-4d7deefbb1bf663c\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG
--- stderr
thread 'main' panicked at '
couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
', C:\Users\Andrew\.cargo\git\checkouts\azul-dependencies-70bb1f94316762f9\bf2933b\cmake-0.1.35\src\lib.rs:687:25
stack backtrace:
0: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.29\src\backtrace\mod.rs:66
...
I installed cmake and visual studio 2019. Also note that I am using clion ide. Cmake version is 3.15.2.
It says I should run the appropriate vcvars script before building this crate, what does it mean exactly?
EDIT ----
Found vcvars.bat in the visual studio installation folder and ran it. It's still getting the same error.
EDIT2 ----
It looks like an incompatibility between the latest version of visualstudio(19) and cmake. Reverting to 2015 is suppose to resolve the issue.
https://github.com/maps4print/azul/issues/203
When you install Visual Studio, the command-line tools are not available from a generic command prompt. Visual Studio should have installed an entry in your start menu to start a properly configured console.
Or if you haven't started your console from this special entry, Visual Studio should also have installed a script called vcvars.bat somewhere in its install folder. You need to run that script before you can access the command-line tools.

LLVM Visual Studio Integration Failed

I'm trying to integrate LLVM with Visual Studio 15 2017, however I seem to be unable to get it to work. When running the LLVM installer after Visual Studio has been installed, I get a command prompt with the following error:
Installing MSVC integration...
Failed to find MSBuild toolsets directory.
MSVC integration install failed.
Press any key to continue . . .
After some research online, I found this SO link which has lead me to believe that the LLVM installer does not know how to install for VS15. As such, I tried installing the toolset found here manually. Now, I can see LLVM listed as a toolset in Visual Studio:
However, when I choose it as an option and try to compile a simple "Hello World" program, I get the following error:
error MSB8020: The build tools for LLVM-vs2017 (Platform Toolset = 'LLVM-vs2017') cannot be found.
To build using the LLVM-vs2017 build tools, please install LLVM-vs2017 build tools.
Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
Is there something I am doing wrong here, or some step I missed when trying to get these two tools integrated?
LLVM Visual Studio Integration Failed
After the test, you should execute the AutoSetup.bat to install the LLVM 6.0.0 automatically.
Plasmacel provided a fork which is updated for LLVM 6.0.0 and provides better integration by providing include and library paths of LLVM/clang. In the file README.MD, you can find the some more details, like Automatic Installation:
Automatic Installation
Open a command prompt with Administrator rights
(DO NOT OPEN AutoSetup.bat with admin rights it won't load the files)
Go to the folder where AutoSetup.bat exists and type "AutoSetup"
If Automatic doesn't work, you can also go to the Manual Installation.
Hope this helps.

Could not launch gdb from Visual Studio for remote debugging Linux C++ project in Linux subsystem on Windows

I am trying out Targeting the Windows Subsystem for Linux from Visual Studio. The project builds fine in Visual Studio:
1>------ Rebuild All started: Project: LinuxConsoleApp, Configuration: Debug x64 ------
1>Cleaning remote project directory
1>Validating architecture
1>Validating sources
1>Copying sources remotely to 'localhost'
1>Starting remote build
1>Compiling sources:
1>main.cpp
1>Linking objects
1>LinuxConsoleApp.vcxproj -> C:\...\LinuxConsoleApp\bin\x64\Debug\LinuxConsoleApp.out
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
I can run it from the bash commandline prompt on Windows:
linux#windows-bash:/mnt/c/.../LinuxConsoleApp/bin/x64/Debug$ ./LinuxConsoleApp.out
hello from LinuxConsoleApp!
However, when I set a breakpoint to debug it from Visual Studio, I got error:
"Could not launch gdb. gdb is missing from your system and needs to be
installed, please use your system's package manager to install it"
I did install gdbserver on the Linux subsystem on Windows. Does anyone know what else I need to make it work? Thanks in advance!
Firstly, have you installed gdb on WSL? What does command gdb --version display?
Then recommend you debug in gdb mode, see this topic for details.
And, if you read the comments in the original Visual Studio blog about using WSL, you will see that there are some issues around ssh which, if you follow the trail, will take you to this fix

Resources