-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Indirect shared libraries built by vcpkg are not found on Linux #16332
Comments
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
|
|
@Fedr For question 2, if the generated debug and release library names are the same, the compiler will find the first path when adding debug/lib and lib to ldconfig. So I think this cannot be solved at present. |
@JackBoosY |
@Fedr There are some differences between Windows and Linux, which makes us temporarily unable to unify the behavior of the two platforms. |
And I remember @BillyONeal mentioned about this. |
In the general case, the platform fights you here; the whole system must agree on the version of any given .so installed in any of the default library paths, because under POSIX all symbols are smashed into a single process-wide symbol table. Only one entity on the system gets to say what vector::vector does, for example. That makes "follow your code" systems like vcpkg and conan unable to provide a fantastic experience for deploying shared libraries. That's why there's no triplet, even under community status, which delivers dynamic libraries on Linux right now; most of the time you have to use what comes with your distro there. This is why the system-wide package managers dnf/yum/apt/etc. took off on Linux: without them getting to a functional system is effectively impossible. (Contrast this with Windows where any program can choose the versions of their dependencies by copying DLLs next to their EXE; you can get much the same effect by statically linking everything which is what we do on the POSIX-ish platforms) |
Thanks for the detailed explanation. The reason why we use shared libraries is because our software package contains a few executables. And if all executables had been statically linked, each of them would be huge in size. So, we are forced to use shared libraries even despite the difficulties discussed here. |
I wonder if I can create a small wrapper app with something like this in main(): |
I know this is what you want, but the POSIX platforms are designed very explicitly to not give you that.
Using current directory would be exploitable and bad. Using relative-to-current-executable may work; I don't know the detailed nitty gritty on when dependencies are resolved in ELF land. |
We could also try to use
This is exactly what we need - relocatable and reproducible builds, same as on Windows. |
To my understanding that only works if the relative path between your exe and the libraries is the same relative path on the build machine and on the customer box, which isn't going to be true here (since we build the libraries in different directories then you deploy them). You might be able to use something like |
I would like to try setting rpath=$ORIGIN in all .so-files built by vcpkg. Could you please suggest how to specify this setting in the triplet? |
We don't have a ready-to-hand option for this. You can try yourself to see if it would work by using patchelf on the resulting binaries though. |
Not sure if you can specify it in triplet, but take a look at the toolchain file: |
I mean if the triplet is as follows:
Then all .so-files produced by vcpkg should search its dependencies in the same folder:
and potentially solve the issue with indirect .so-dependencies. But probably I miss something? |
You can try it and report back; like @BillyONeal mentioned, this is a thorny issue that is counter to the way software is typically built and distributed for these platforms. |
This is fixed in #23035 |
I use vcpkg to build a number of packages on Linux as shared libraries (.so-files) using the setting
in the triplet.
It works fine, but there is a problem with shared libraries that are not directly referenced by my application. For example, my program uses libblosc library, which depends on liblz4 library. So when starting the program I get a dynamic linker error. And not surprisingly, because ldd output is as follow:
And libz4.so is present in the same folder with libblosc.so.1, but it is not searched there because it is not the direct dependency of the application.
Is there a way to install dynamic packages in vcpkg on Linux and make sure that just built application will find them?
The text was updated successfully, but these errors were encountered: