Closed darbyford closed 2 months ago
Samples are built as libraries and can't be run that way. You need to select and start the "vulkan_samples" project and pass the name of the sample you want to run as an argument.
Running from Windows command line didn't work:
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64>vulkan_samples.exe sample compute_nbody
Running Vulkan Samples from VS in mode Release x64 didn't work. It briefly pops-up a Window, then closes it, and doesn't issue any errors.
Running Vulkan Samples from VS in mode Debug x64 didn't work. It pops-up a Window, saying that no sample name was given in the invocation. AFAIK there's no way to provide arguments to the program when running from VS.
[error] Error Message: Failed to open file for reading
You're probably running in the wrong working directory and the sample isn't able to find it's assets.
Step 1. Ran git clone into this empty directory: D:\My Programs\C++\Vulkan Samples> git clone --recurse-submodules https://github.com/KhronosGroup/Vulkan-Samples.git
Git clone created a new container sub-directory, also called "Vulkan Samples\"
So after git clone the new pathname to the samples is: D:\My Programs\C++\Vulkan Samples\Vulkan Samples\
Step 2. Ran this cmake command to generate the Visual Studio 2022 project and solution files: Used the full pathname to cmake.exe D:\My Programs\C++\Vulkan Samples\Vulkan Samples> C:\cmake-3.30.3-windows-x86_64\bin\cmake -G "Visual Studio 17 2022" -A x64 -S . -Bbuild/windows
Step 3. Ran this cmake build command: D:\My Programs\C++\Vulkan Samples\Vulkan Samples> C:\cmake-3.30.3-windows-x86_64\bin\cmake --build build/windows --config Release --target vulkan_samples
One of the README files in the git repo instructions says this:
> Make sure that you are running the samples from the root directory of the repository.
> Otherwise the samples will not be able to find the assets.
> ./build/app/bin/<BuildType>/<Arch>/vulkan_samples
That directory doesn't exist in my build, which suggests that the README file is out of date.
MY NOTE:
This directory doesn't exist, where <BuildType> = Windows and <Arch> = AMD64 or x64, etc.
./build/app/bin/<BuildType>/<Arch>/vulkan_samples
From git repo, the Windows build guide, located here: https://github.com/KhronosGroup/Vulkan-Samples/blob/main/docs/build.adoc#windows and shown partially but more fully below, says this:
That is the actual directory that contains vulkan_samples.exe in my build: D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64\vulkan_samples.exe
But this "assets" directory is empty: D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64\assets
Perhaps should have run the cmake commands in steps 2 and 3 from another directory, instead of this one ? : D:\My Programs\C++\Vulkan Samples\Vulkan Samples>
The build guide from Vulkan Samples git repo doesn't specify the directory from which to run the cmake build commands : The build guide is located here: https://github.com/KhronosGroup/Vulkan-Samples/blob/main/docs/build.adoc#windows
The readme is correct.
You need to run the binary with the root of the sample repo as the working directory. The easiest way is to run it from the IDE.
If that's not possible, run it from the root just like specified at the end of your screenshot.
E.g.:
cd v:\vulkan_samples
\build\windows\app\bin\debug\AMD64\vulkan_samples.exe sample compute_nbody
`D:>cd d:\vulkan_samples The system cannot find the path specified.
You obviously need to cd into the path where the samples are located on YOUR system.
I changed to My path where vulkan_samples.exe is located, here:
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64
I then ran vulkan_samples.exe requesting compute_nbody
The run command:
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64>vulkan_samples.exe sample compute_nbody
compute_nbody popped a Window, failed to execute properly, and closed the Window.
I think the build is faulty.
Note that the "assets" directory is empty:
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64\assets>dir
Volume in drive D is DATADRIVE1
Directory of D:\My Programs\C++\Vulkan Samples\Vulkan-Samples\build\windows\app\bin\release\AMD64\assets
09/03/2024 10:34 PM <DIR> .
09/03/2024 10:34 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 1,877,288,681,472 bytes free
You need to run with the working directory being the root of the samples. You still try to run from the wrong folder. cd to the root folder where you cloned the sample and execute the .exe from there I can't explain it any easier than that.
Success, thanks for your patience !
Did this:
D:\>
D:\>
D:\>cd D:\My Programs\C++\Vulkan Samples\Vulkan-Samples
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples>
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples>
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples>build\windows\app\bin\Release\AMD64\vulkan_samples.exe sample compute_nbody
So now that Windows command works, how do you run samples from VS IDE ?
Did a fresh git clone. Windows command works:
D:\MyProg\Vulkan-Samples> build\windows\app\bin\release\AMD64\vulkan_samples.exe compute_nbody
VS solution loads. VS project "vulkan_sample" builds. Running VS project "vulkan_sample" errored out with this:
[info] Logger initialized
[info]
[info] No sample was requested or the selected sample does not exist
[info]
[info] To run a specific sample use the "sample" argument, e.g.
[info]
[info] vulkan_samples sample hello_triangle
[info]
[info] To get a list of available samples, use the "samples" argument
[info] To get a list of available command line options, use the "-h" or "--help" argument
[info]
Press return to continue
Is there a way to pass arguments ( e.g. "sample compute_nbody" ) to VS project "vulkan_sample" when starting it?
Found a way to pass arguments to VS project "vulkan_sample" before starting it. Kludgy way to run samples but it works:
Project | Props | Config: Release | Config Properties | Debugging | Command Args | Add: sample hello_triangle
Project | Props | Config: Debug | Config Properties | Debugging | Command Args | Add: sample hello_triangle
Use this to simplify that: https://marketplace.visualstudio.com/items?itemName=MBulli.SmartCommandlineArguments2022
Will try it, thanks
github clone, success (see log below)
cMake to Visual Studio 2022 files, success (see log below)
cMake to Build, success (see log below)
Launch Visual Studio 2022 solution from ...\Vulkan-Samples\build\windows, success:
Set compute_nbody as the Startup Project.
Run Debug x64 and Release x64, with or without debugger, fail:
Error out with: ...\Debug\compute_nbody.lib is not a valid Win32 application ...\Release\compute_nbody.lib is not a valid Win32 application
Running from Windows command line didn't work:
...\Vulkan-Samples\build\windows\app\bin\release\AMD64>vulkan_samples.exe compute_nbody
Error out with: ...\Vulkan-Samples\build\windows\app\bin\release\AMD64>[info] Logger initialized [error] CLI11 Parse Error: [vulkan_samples] The following argument was not expected: compute_nbody
D:\My Programs\C++\Vulkan Samples>git clone --recurse-submodules https://github.com/KhronosGroup/Vulkan-
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples>C:\cmake-3.30.3-windows-x86_64\bin\cmake -G "Visual Studio 17 2022" -A x64 -S . -Bbuild/windows
D:\My Programs\C++\Vulkan Samples\Vulkan-Samples>C:\cmake-3.30.3-windows-x86_64\bin\cmake --build build/windows --config Release --target vulkan_samples