From Frustration to Seamless Integration: Essential Tips and Proven Solutions for vcpkg with C++ Development #42579
Replies: 1 comment 1 reply
-
It probably saves time to not use GPT at all if you need accurate information.
All proper CMake packages do carry the transitive usage information. So you do not need to add transitive dependencies in most cases. However, it is mandatory to use the vcpkg toolchain, In addition, CMake demands that |
Beta Was this translation helpful? Give feedback.
-
Hi.
I hope we all help each other to improve knowledge by sharing experiences.
I have a project with C++ and need to use the mailio library to make an OTP login with mail for specific users. First, I tried on Windows 10, and after that, I tried on Windows 11. Here is some information to share:
What needs to be installed and can work with vcpkg:
*You need Build Tools & SDKs (This is really important!)
-> For this option, you can download it from Microsoft or just install it using the Visual Studio installer
*If your system username has a space, you might encounter issues
For example: c:/user/M M/vcpkg..... This can cause many problems in the system environment or in the CMake files for target libraries by vcpkg and more... But I found a way to fix this issue :) First, in the system environment, you should delete the vcpkg root (This is important for CLion IDE users) Second, you can use this code in cmd or terminal to get the binary form for the path with spaces:
for %I in ("C:/Users/your user name/....") do @echo %~sI
*GPT or other AIs do not work and can't return you the correct answer for these, really! It just wastes your time!!!
The best way to fix your issues with vcpkg is to read the documentation from Microsoft. Here are the most important links:
*CMakeLists.txt has problems finding installed libraries with vcpkg!!
Maybe you finally install your libraries, but when you use them in the main code, you see an error saying it can't find the libraries!... WTH?!
For this issue, you should have good knowledge about CMake and vcpkg (This is really important)
After you install libraries with vcpkg, the last line returns some lines to be added in the CMakeLists.txt
But after you add them, it still can't find the libraries!
So what's the answer?!
Some libraries have dependencies, and you should first call them and then call your libraries in CMakeLists.txt You can see the dependencies for all packages at https://vcpkg.io/en/package For example, after many tries for mailio, I found the following solution to make CMake find it:
Common bugs for these parts:
project(project)
And an important part is the order; if you try to change this order, you might see some problems. For this, getting help from GPT can be useful.
For CLion users....
In the "Settings" under the "Build, Execution, Deployment" section & in the CMake options, you should check it with GPT to understand and fix some problems from there :)
So this is my experience. I hope it is helpful, and if you know more, please share it with us.
Thanks for reading :)
Beta Was this translation helpful? Give feedback.
All reactions