microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.35k stars 6.45k forks source link

Attempting to link library A -> static B -> dynamic #39504

Closed 3UR closed 5 months ago

3UR commented 5 months ago

I am completely unsure how to do so here are some details

Environment

Vcpkg is in manifest mode Using Visual Studio 2022

Issue

if I go to Properties -> vcpkg -> Use Static Libraries it will try to make every library in my vcpkg.json linked statically, this is an issue because I also use Qt 5 which doesn't support me statically linking

So my question is if I have for example sdl2 in my vcpkg.json and I want to link that statically but everything else dynamic how would I go doing so

3UR commented 5 months ago

Also this is NOT an huge issue for me if I can't do it but I honestly like having minimal DLLs

3UR commented 5 months ago

This is what happens when I attempt to set Use Static Libraries to True on a project which doesnt even use Qt 5 but just uses the same manifest

1>Loading dependency information for 170 packages...
1>qt5-webengine is only supported on '!static', which does not match x86-windows-static. This usually means that there are known build failures, or runtime problems, when building other platforms. To ignore this and attempt to build qt5-webengine anyway, rerun vcpkg with `--allow-unsupported`.

I hope that there is an way to make specific libraries statically linked

3UR commented 5 months ago

This is what happens when I attempt to set Use Static Libraries to True on a project which doesnt even use Qt 5 but just uses the same manifest

1>Loading dependency information for 170 packages...
1>qt5-webengine is only supported on '!static', which does not match x86-windows-static. This usually means that there are known build failures, or runtime problems, when building other platforms. To ignore this and attempt to build qt5-webengine anyway, rerun vcpkg with `--allow-unsupported`.

I hope that there is an way to make specific libraries statically linked

It's also an issue because this project out of many is a installer for my app and it should not require DLLs they should all be statically linked

LilyWangLL commented 5 months ago

The error message indicates that the library you are trying to install depends on qt5-webengine, but qt5-webengine does not support static. You can try adding the option --allow-unsupported to the install command to install this port.

Osyotr commented 5 months ago

https://learn.microsoft.com/en-us/vcpkg/users/triplets#per-port-customization

dg0yt commented 5 months ago

You can try adding the option --allow-unsupported to the install command to install this port.

Or you you better don't waste time on it, for qt5-webengine.

https://learn.microsoft.com/en-us/vcpkg/users/triplets#per-port-customization

Or you you better don't waste time on it, for qt5-webengine.

I also use Qt 5 which doesn't support me statically linking

I was wondering why you were claiming that, but ...

qt5-webengine is only supported on '!static'

... the actual problem is qt5-webenginge? Please check: is it really needed (direct dependency), or did some manifest added qt5 out of laziness? qt5 means ALL of qt5, and that's almost never true.

3UR commented 5 months ago

The error message indicates that the library you are trying to install depends on qt5-webengine, but qt5-webengine does not support static. You can try adding the option --allow-unsupported to the install command to install this port.

Nothing in this project where I want to enable static linking requires qt5-webengine all of the C++ code uses boost but I do have other projects what depend on qt5-webengine (completely unrelated to this installer project though)

here is a example of my structure

- project1
- project2
- vcpkg_installed
- xxx.sln
- vcpkg.json

project1 and project2 share the same manifest for Vcpkg, project1 is a installer which uses only boost, project2 is an ide which uses Qt 5 and qt5-webengine

project1 does not use anything from project2 either only they share the same manifest

3UR commented 5 months ago

You can try adding the option --allow-unsupported to the install command to install this port.

Or you you better don't waste time on it, for qt5-webengine.

Yep, I want to enable static linking for everything except for Qt

I also use Qt 5 which doesn't support me statically linking

I was wondering why you were claiming that, but ...

qt5-webengine is only supported on '!static'

... the actual problem is qt5-webenginge? Please check: is it really needed (direct dependency), or did some manifest added qt5 out of laziness? qt5 means ALL of qt5, and that's almost never true.

qt5-webengine is not a dependency of my project where I wanna enable static linking but it does use the same manifest as my project which uses qt5-webengine

I just am wondering would there be some kind of way to select what libraries I want static linking for manually?

dg0yt commented 5 months ago

I just am wondering would there be some kind of way to select what libraries I want static linking for manually?

You can change it for select ports by triplet file customization. This is the link in https://github.com/microsoft/vcpkg/issues/39504#issuecomment-2188310582

But I wouldn't be too optimistic about a dynamic qt5-webengine monster (with some dependencies not de-vendorered) working well with everything else being static.

3UR commented 5 months ago

I just am wondering would there be some kind of way to select what libraries I want static linking for manually?

You can change it for select ports by triplet file customization. This is the link in #39504 (comment)

But I wouldn't be too optimistic about a dynamic qt5-webengine monster (with some dependencies not de-vendorered) working well with everything else being static.

Is this CMAKE only?

dg0yt commented 5 months ago

Is this CMAKE only?

This is general vcpkg.

CMake is the general scripting language in vcpkg. It doesn't imply that you have to use CMake for your projects.

3UR commented 5 months ago

@dg0yt So from my understanding I will have to edit? %vcpkg_root%\triplets\x86-windows.cmake

3UR commented 5 months ago

I guess I will have to clone vcpkg into my repo now because currently it is installed with Visual Studio X:\Program Files\Microsoft Visual Studio\2022\Preview\VC\vcpkg but obviously ediitng x86-windows.cmake on my side only to be static isnt really a good idea

3UR commented 5 months ago

Ok I am now using a submodule for vcpkg I will close this

dg0yt commented 5 months ago

Note that vcpkg also has "overlay triplets" - so it could work with VS vcpkg.