Tools a C++ programmer may need

Pages: 123
BTW, frek, I have to thank you for pushing me to figuring out how to properly use vcpkg. I'd dinked around in the past, and gave up with the impression it was harder to work with than it actually is.

I've successfully installed for x86 and x64 Catch2. I noticed there are .md docs in the installed directories, so I peeked and LO! Decent documentation on using Catch2.
I've also installed the {fmt} library, and the installation automatically built the .dll and .lib files. So I can have dynamic or static linking.

SUH-WEET!

vcpkg really is a tool needed if one uses Visual Studio.
No problem and thank you all for helping me.

Still I can't use Catch2 in my IDE: VS 2022 (community)
As I said in my previous post, I get the following two errors when I include the header: #include <catch.hpp>

Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "catch.hpp"

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'catch.hpp': No such file or directory


As well as, I searched for that header file (catch.hpp) in the vcpkg folder. There's not such a file there either! :|
Last edited on
Do you have an installed folder under where you installed vcpgk? Installed packages go there. Inside subfolders for x86 and x64 versioning.

Did you vcpgk integrate install before you installed Catch2? That is key to getting the installed packages to be discoverable by VS without a hassle.

Try vcpkg list, that shows all packages you've got installed.

You shouldn't have VS running when you install packages, or at least close and restart VS to discover what vcpkg has installed.

Do you have an installed folder under where you installed vcpgk? Installed packages go there. Inside subfolders for x86 and x64 versioning.
There's a folder with the same name as vcpkg right inside it. That is, the path from the C drive to the subfolders and files is this way: C:\dev\vcpkg\vcpkg

Did you vcpgk integrate install before you installed Catch2? That is key to getting the installed packages to be discoverable by VS without a hassle.
As stated in my prior post, I firstly cloned the vcpkg.git file from its git repository as written in the link. Then ran the following two command one after another:
.\vcpkg\bootstrap-vcpkg.bat
vcpkg integrate install


For example this is the output of CMD when running the last command:

C:\dev\vcpkg\vcpkg>vcpkg integrate install
Applied user-wide integration for this vcpkg root.

All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake"

C:\dev\vcpkg\vcpkg>


Try vcpkg list, that shows all packages you've got installed.
I get this for that command!
C:\dev\vcpkg\vcpkg>vcpkg list
No packages are installed. Did you mean `search`?

C:\dev\vcpkg\vcpkg>

:(
Last edited on
This round of hassles is why I gave up when I tried to use vcpgk earlier. Trying to help you helped me to get a better handle on how vcpkg works.

Somehow you buried vcpgk one directory down into a second vcpkg folder. Navigate to that second vcpkg dir and look to see if there is an installed folder. As well as a lot of other folders like .github, buildtrees, docs, etc. along with a bunch of standalone files including vcpkg.exe. If you find that in the second vcpk dir then things aren't so dire.
I'm figuring out that you don't want to actually be IN the directory where you want to install vcpkg when you do the git clone, you want to be one dir UP. The git clone creates the vcpkg dir for you.

For instance, if you want vcpkg to be in C:\dev\vcpkg when it is installed, then issue the git clone command from C:\dev.

The "getting started" instructions could be better written.
Last edited on
I'm very confused now! :(
Here is what my vcpkg folder looks like: https://imgur.com/kFUsgAf

As you see there're many files and subfolders there but not one named "installed"!

I don't know how many folders I should create and within which I should run the git clone command!

Firstly I created two folders: dev and inside it vcpkg and inside that vcpkg ran the git clone command. VS didn't recognize the header.
Secondly, removed the previous folder and start from beginning by creating only one folder called dev and from within that ran the git clone command. Yet, VS doesn't recognize the header! :(
Last edited on
THAT looks correct as far as it goes IMO.

Notice NO installed folder yet. You haven't installed catch2 (or any libraries) yet.

Before we continue let's do a bit of basic house-keeping....

Start a project in VS, any project. New or existing one.

Check the project's properties. Do you see an entry under Configurations Properties for vcpkg? Likely near the top of the list. It is the 3rd entry for me.

If not, then you haven't done the global integration yet as far as VS and vcpkg are concerned. DO NOT issue the global integration command just yet! That is another step we will do in a bit.

If you do see vcpkg in the Configuration Properties we are along the right path towards success. Still not there yet, but one step closer.
Last edited on
I'm very confused now! :(

Now you know how I felt when I was first learning to use vcpkg, without ANY help. All by myself.
To ensure you get a working vcpkg install properly integrated into VS please let's do this one step at a time. You've got what looks like a good vcpkg install in C:\dev\vcpkg. I'll walk you through each step I used to get it to work for me.

So you know the intricacies of how it works, etc.

A plus is anyone who hasn't worked with vcpkg before can benefit from both of our trials and tribulations experience. :)
Last edited on
After vcpkg integrate install command I searched for "Catch2" on CMD and then installed it. Now Visual Studio recognizes the header and "vcpkg" is also the third entry in Configuration Properties.

Is it now done for installing and enabling Catch2 on my IDE, please? :)
Issue a vcpkg list command. To properly use catch2 I recommend you have two versions installed.

One for x86, another for x64.

Here's my installed packages list:
catch2:x64-windows                                 2.13.8           A modern, header-only test framework for unit te...
catch2:x86-windows                                 2.13.8           A modern, header-only test framework for unit te...
fmt:x64-windows                                    8.1.0            Formatting library for C++. It can be used as a ...
fmt:x86-windows                                    8.1.0            Formatting library for C++. It can be used as a ...
vcpkg-cmake-config:x64-windows                     2021-12-28
vcpkg-cmake-config:x86-windows                     2021-12-28
vcpkg-cmake:x64-windows                            2021-12-20
vcpkg-cmake:x86-windows                            2021-12-20
Last edited on
C:\dev\vcpkg\vcpkg>vcpkg list
catch2:x86-windows                                 2.13.8           A modern, header-only test framework for unit te...
vcpkg-cmake-config:x64-windows                     2022-02-06
vcpkg-cmake:x64-windows                            2022-01-19
There are other vcpkg commands you should get to know.

vcpkg help shows the basic commands available.
installed both:

C:\dev\vcpkg\vcpkg>vcpkg list
catch2:x64-windows                                 2.13.8           A modern, header-only test framework for unit te...
catch2:x86-windows                                 2.13.8           A modern, header-only test framework for unit te...
vcpkg-cmake-config:x64-windows                     2022-02-06
vcpkg-cmake:x64-windows                            2022-01-19

C:\dev\vcpkg\vcpkg>
As I suspected, only the x86 version was installed. VS 2022 defaults to being x64 for new projects. You need to install the x64 version now.

.\vcpkg install catch2:x64-windows

Do a list to ensure you now have both versions.

Wanna guess how you explicitly install the x86 version?

.\vcpkg install catch2:x86-windows
I'd also recommend you install the x86 versions of vcpkg-cmake and vcpkg-cmake-config while we're at it. It never hurts to be thorough.
C:\dev\vcpkg\vcpkg>vcpkg list
catch2:x64-windows                                 2.13.8           A modern, header-only test framework for unit te...
catch2:x86-windows                                 2.13.8           A modern, header-only test framework for unit te...
vcpkg-cmake-config:x64-windows                     2022-02-06
vcpkg-cmake-config:x86-windows                     2022-02-06
vcpkg-cmake:x64-windows                            2022-01-19
vcpkg-cmake:x86-windows                            2022-01-19

C:\dev\vcpkg\vcpkg>


Is it now good enough? :)
Only you can determine if that is "good enough." It appears you've got VS and vcpkg integrated as it should be to work as advertised.

Personally there are other libraries I might look at installing. Boost for one. But then that's me.

You will find documentation for catch2 buried in the installed folder, I'll let you have some fun hunting for it.

As I suggested earlier: there are other vcpkg commands you should get familiar with, how to determine if any installed packages have updates, etc.
Pages: 123