How to use vcpkg installed packages in Visual Studio in reality?
Asked Answered
O

1

11

It is written here

In Visual Studio, you can create a New Project (or open an existing one). All installed libraries are immediately ready to be #include'd and used in your project without additional configuration.

Which is not true in reality. If I do New Project and create either Console or CMake application from scratch and have some CGAL includes (since I have CGAL installed in vgpkg) I am (obviously) getting error messages, saying that CGAL includes are not found.

How to fix? May be put path to vcpkg somewhere in Visual Studio or something?


vcpkg integrate install also doesn't help.

D:\dev\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=D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"

It claimed it will work, but it doesn't

enter image description here

And it is obviously, because there is not magic in the world.

So, what else from "without additional configuration" I forgot?

Office answered 22/1, 2020 at 17:56 Comment(24)
Did you run vcpkg integrate install?Blythe
I don't remember. Anyway it IS SOME configuration required :)Office
It's written in the docs. You clone vcpkg, run the build script, and do a one-time vcpkg integrate install. Literally at the top of the readme file you linked.Blythe
https://github.com/microsoft/vcpkg/blob/master/docs/users/integration.md#integrateBandicoot
"what else from "without additional configuration" I forgot?" How can we know? We're not at your computer, and we didn't follow the instructions at your computer, so we can't know what steps you missed.Guadalcanal
Did you actually build the project? Intellisense isn't always reliable.Blythe
@Blythe it doesn't work; and I would say it can't work, please, read the statement: to all VS2015 and VS2017 MSBuild projects. Should it scan my several terabytes HDD to find these projects first?Office
@NicolBolas just say what is wrong with the statement, that configuration is not required. Fix it.Office
It looks like you are using CMake for your project. The instructions for CMake are different. With CMake I use the toolchain file and configure using CMake-gui.Bandicoot
That's not how it works. There are default paths that are inherited by each project IIRC. There is no magic scanning happening. Also does your triplet match the installed libraries?Blythe
Also , your console output says CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"Blythe
@Blythe what is "triplet"? I can run CGAL examples with building SLN files with cmake-gui. Here I am asking, how to get "you can create a New Project (or open an existing one). All installed libraries are immediately ready to be #include'd and used in your project without additional configuration" in reality?Office
@Blythe I can set toolchain it cmake-gui, yes. I am asking about zero configuration of creating new projects in VS.Office
https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.mdBandicoot
Then use a Visual Studio project format instead of cmake if you are not willing to copy & paste one line of code.Blythe
@Bandicoot so "no additional configuration" means actualy "read tons of manuals and try to figure out what to configure actually", it's okayOffice
Its no configuration for Visual Studio projects. For CMake based projects I believe you have to tell CMake about the toolchain file.Bandicoot
It means you don't need to do anything if you use a vcproj project format. If you use cmake you have the burden of pasting one line of code in your .cmake file.Blythe
@Bandicoot it doesn't work with "no configuration" for VS project too. How would it? It shoudl have paths to libraries and includes in property pages. Who would put it there?Office
@Blythe vsproj doesn't work either; why would it? there is no magic; somebody should put settings into project properties, which was not done of course.Office
@Dims: "just say what is wrong with the statement" I did say what's wrong with your statement: that you can't expect people to remotely fix a problem local to your machine. I don't have anything to say about the statement from the documentation.Guadalcanal
I wish it. But it will not be "no additional configuration". I was just surprised, reading this. Fortunately, this is not true.Office
@NicolBolas my machine is ok :) zero configuration is not ok :)Office
Should I run vcpkg integrate install on macOS/Linux also or that's a Visual Studio thing?Evania
O
4

It was a "triplet" problem (x86 was set instead of x64).

Office answered 22/1, 2020 at 19:59 Comment(3)
x86 is the default. There is an issue asking to change the default to 64 bit however no action has been taken: https://github.com/microsoft/vcpkg/issues/1254Bandicoot
could you elaborate on this? I'm having the same issue.Pagurian
I'm having a similar issue and I have no idea what this means in the slightest.Barrel

© 2022 - 2024 — McMap. All rights reserved.