Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can TRIPLET be used with vcpkg.json #21917

Closed
iXavierLiu opened this issue Dec 8, 2021 · 15 comments
Closed

Can TRIPLET be used with vcpkg.json #21917

iXavierLiu opened this issue Dec 8, 2021 · 15 comments
Assignees
Labels
category:question This issue is a question

Comments

@iXavierLiu
Copy link

Please create a discussion in https://github.com/microsoft/vcpkg/discussions/new instead.

$.dependencies[0] (a dependency): must be lowercase alphanumeric+hyphens, split with periods, and not reserved

I can fin'd a way to set TRIPLET in vcpkg.json, and I need to depend a static link static runtime(/MT) library, I may need to use dynamic/static libraries for different libraries, so I cannot set the environment variables uniformly. Is there any way to solve this problem?

@Neumann-A
Copy link
Contributor

you don't set/use the triplet in vcpkg.json. If you need specific combinations of VCPKG_LIBRARY_LINKAGE you have to define a custom triplet for it.

@iXavierLiu
Copy link
Author

iXavierLiu commented Dec 9, 2021

you don't set/use the triplet in vcpkg.json. If you need specific combinations of VCPKG_LIBRARY_LINKAGE you have to define a custom triplet for it.

I can't find the option to set TRIPLET for each dependency in the documentation, I want to implement the following idea, how should I write?
{ "name": "Test", "version-string": "0.1.0", "dependencies": [ "openssl:x86-windows-static-md", "zlib:x86-windows" ] }

@Osyotr
Copy link
Contributor

Osyotr commented Dec 9, 2021

@LilyWangLL LilyWangLL added the category:question This issue is a question label Dec 9, 2021
@JackBoosY
Copy link
Contributor

We hope your question was answered to your satisfaction; if it wasn't, you can reopen with more info.

@0blu
Copy link

0blu commented Mar 9, 2022

This should be a feature request.
I know technically every repository should use a fork / submodule of vcpkg where adding a custom triplet is not a problem,
but I think adding triplet support to vcpkg.json sounds very logical.

@Osyotr
Copy link
Contributor

Osyotr commented Mar 9, 2022

@0blu it sounds logical if you target only one platform, configuration and build tools version.

@TheMaverickProgrammer
Copy link

TheMaverickProgrammer commented Feb 13, 2023

Hi I agree with 0blu. I'm having vcpkg issues because the triplet for one of my packages is defaulting as static on ubuntu whereas on windows it can be dynamic (which is defaulted on windows). I would need to explicitly call for the dynamic triplet on ubuntu to have my scripts build and deploy my project.

This means my current CI/CD scripts are busted if I depend on vcpkg,json to do the installation for me. We should really have this feature.

@dg0yt
Copy link
Contributor

dg0yt commented Feb 13, 2023

vcpkg has some ports which must be built with either static or dynamic linkage regardless of triplet.
And you can add per-port customization to your triplet file for ports which support both types.
In any case, there is a single triplet which defines your target universe.

@dg0yt
Copy link
Contributor

dg0yt commented Feb 13, 2023

@TheMaverickProgrammer Probably it is best to ask for help with what you want to achieve in a new discussion.

@abdelmaged
Copy link

One of the disadvantages of using per port customization, is when you change the triplet file to customize one port, all other ports will recompile, this is why I don't find this feature very practical, I think it would be better, if one can specify the triplet per dependency in the vcpkg.json instead.

@Neumann-A
Copy link
Contributor

There is a way to avoid it. Simply include a file with the specialization but be aware it has implications.

@TheMaverickProgrammer
Copy link

There is a way to avoid it. Simply include a file with the specialization but be aware it has implications.

Avoiding is not a solution. And you even imply it has undesirable outcomes. Not good.

@iXavierLiu
Copy link
Author

I haven't paid attention to this discussion for a long time. My initial thought is very simple:
foobar.exe requires two libraries, foo.lib and bar.dll.
foo.lib is a x86-windows-static-md static library,
bar.dll is an x86-windows dynamic library,
Both libraries are dynamic runtime (/MD)
What is finally provided to the user is foobar.exe and bar.dll, which is very common in traditional engineering projects.

The issue is:
If I specify the same TRIPLET, two dynamic libraries need to be provided under x86-windows, or both libraries will be used as static library dependencies under x86-windows-static-md.

Am I missing something, or is there a way I can achieve what I'm thinking above?

@yhyu13
Copy link

yhyu13 commented May 11, 2024

The easiest thing is simply modifying the port/port***.cmake file for specific libaray and adjust VCPKG_LIBRARY_LINKAGE to dynamic temporaly, like I did here for luajit in linux-x64. Now linux-x64 build liblujit.so by default. No need to inflict custom dynamic triplet https://github.com/yhyu13/vcpkg/blob/84bc6197cf22f9cdc777090d6715988f6aea16ed/ports/luajit/portfile.cmake#L21

@dg0yt
Copy link
Contributor

dg0yt commented May 12, 2024

A Simply modifying the port/port***.cmake file for specific libaray

Don't do that. It is not a customization point.

The triplet fcontrols the linkage. And it is a valid customization point in particular for non-standard linkage. Take one of the two triplets files as a base, and use per-port customization.
https://learn.microsoft.com/en-us/vcpkg/users/triplets#per-port-customization

Instead of

foo.lib is a x86-windows-static-md static library,
bar.dll is an x86-windows dynamic library,

this would better be presented as:

foo.lib is a static lib (/MD) in x86-windows-custom.
bar.dll is a DLL (/MD) in x86-windows-custom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

10 participants