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
Create and install shared library with version on MinGW #663
Conversation
In package-oriented distributions like openSUSE, shared libraries are usually installed with a version to better handle dependencies between packages. The main rationale is to allow for two or more (incompatible) versions of a shared library, such as libfoo.so.1 and libfoo.so.2 to be independently selectively installable (and trackable by rpm) at the same time without causing package conflicts. To achieve this also for MinGW based packages installed on a distribution, the shared library 'vsg' for this compiler is also created and installed with version.
I'm reluctant to add platform specific special cases, I would like to explore exactly what the VSG installs right now on MingW without these changes, and what it does with them. For reference on my Kubuntu system when I compile as shared library and install I see the libs: $ ls ~/Install/lib/libvsg*.so* -1 From the sound of it you are trying to replicate this in MinGW, but I'm not clear what parts you've replicated, what parts you haven't. Having things work different on different platforms is not idea, but fitting in with local contents is also needs to be born in mind. I presume other CMake users have this same issue under MinGW/Windows so perhaps CMake itself could provide the behavior rather than having to replicate it in our local CMake scripts. |
An installation of the mentioned files on an openSUSE 64bit distribution would lead to the following results
These files would be put into two packages:
On the same distribution, an installation of mingw32-libvsg creates
These files would also be placed in two packages:
Only the shared library should be changed, which should get a suffix
For vsg this should be done by changing from
to
using the current SOVERSION.
In the current cmake version 3.25, according to current knowledge, such support is not included, so it has always been done in the local CMake scripts (see osg for example). I will open a corresponding request and submit a matching patch. The patch, if accepted, would probably not be included before cmake version 3.27, i.e. until this version is widely distributed, one would have to make do with the current patch. If it is known with which version the patch will be released, one could change to the use the new cmake build-in support with this
Update: see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8021 for an associated request. |
Thanks for the explanation. Is there any reason why we shouldn't apply the -${SO_VERSION} to all Windows shared library builds? My preference would be for Windows have libvsg-${SO_VERSION}.dll and libvsg.a that references it, regardless of the build tool you use. The .dll.a seems a bit awkward but I can see that it would allow one to build a static and shader library version of the VSG and install it on one system, so can see value in using that. Are other projects using the .dll.a convention? |
For the local patch, it can be easily extended by using
Unfortunately, the compilers and build systems see it differently.
There are fixed conventions built into the buildsystems and compilers/linkers. e.g. for the filename suffix cmake:set(MAKE_SHARED_LIBRARY_SUFFIX and prefix: msvc uses none, MinGW 'lib', cygwin 'cyg' etc. cmake:set(MAKE_SHARED_LIBRARY_PREFIX)
Yes, that's the advantage, you install both if you want to and decide later which variant you want to use. With msvc you don't have this possibility to distinguish, so often a workaround is used and Do other projects use the .dll.a convention? According to cmake git repo, cygwin gcc, clang and mingw gcc understand this extension .dll.a and so do other common build systems like meson, qmake. |
Thanks for the links. I've had a read through and understand the topic a little better now. My current thought is that the Visual Studio Windows .dll should have the SOVERSION as well, so using WIN32 seems appropriate. I will merge as is then we can create a branch to test using this for all of WIN32. |
I have done the merge and then changed the CMake check to use WIN32 rather than MINGW, the branch is: https://github.com/vsg-dev/VulkanSceneGraph/tree/Windows_SOVERSION_dll I'll watch the automated builds now to see is things still compile OK, if it does we'll need Windows users using VS, MinGW and Cygwin to test it out before we merge with VSG master. I'll make a 1.0.3 release for this and other changes before Christmas. |
I see
The VC build shows that the installed file names are as expected:
The vsg-dev related CI build jobs for mingw was not triggered by this branch and only generates static libraries
The vsg-dev related CI build jobs for cygwin was not triggered by this branch and only generates static libraries |
I think it's safe enough to merge with master so I've gone ahead and merged and have started the windows-mingw-cygwin action: https://github.com/vsg-dev/VulkanSceneGraph/actions/runs/3712142913 |
Please note that these jobs are not building a shared library. |
It is required to add -DBUILD_SHARED_LIBS=1 to https://github.com/vsg-dev/VulkanSceneGraph/blob/master/.github/workflows/win-cygwin-mingw.yml#L27 and https://github.com/vsg-dev/VulkanSceneGraph/blob/master/.github/workflows/win-cygwin-mingw.yml#L65 to see this change. |
Description
In package-oriented distributions like openSUSE, shared libraries are usually installed with a version to better handle dependencies between packages.
The main rationale is to allow for two or more (incompatible) versions of a shared library, such as libfoo.so.1 and libfoo.so.2 to be independently selectively installable (and trackable by rpm) at the same time without causing package conflicts.
To achieve this also for MinGW based packages installed on a distribution, the shared library 'vsg' for this compiler is also created and installed with version. Since the name of the generated import library is not affected, there are no changes for dependent packages.
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: