KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 647 forks source link

Unable to start program ...\Debug\compute_nbody.lib is not a valid Win32 application #1151

Closed darbyford closed 2 months ago

darbyford commented 2 months ago

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

SaschaWillems commented 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.

darbyford commented 2 months ago

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.

SaschaWillems commented 2 months ago

[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.

darbyford commented 2 months ago

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: zzz Vulkan Sample Docs - Root Directory 2024-09-04-003

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

zzz Vulkan Sample Docs Build with cMake 2024-09-03

SaschaWillems commented 2 months ago

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
SaschaWillems commented 2 months ago

`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.

darbyford commented 2 months ago

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
SaschaWillems commented 2 months ago

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.

darbyford commented 2 months ago

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
darbyford commented 2 months ago

So now that Windows command works, how do you run samples from VS IDE ?

darbyford commented 2 months ago

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?

darbyford commented 2 months ago

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
SaschaWillems commented 2 months ago

Use this to simplify that: https://marketplace.visualstudio.com/items?itemName=MBulli.SmartCommandlineArguments2022

darbyford commented 2 months ago

Will try it, thanks