Merged
Conversation
Contributor
Author
|
Hope that this helps with review: |
6 tasks
Member
|
Looks good to me! With the note that we also use this Can't comment on |
Member
|
Found this commit from 2020 that fixes the referenced curl commit above from 2012: It seems to be something that will hit libssh2 too for static-only builds, after merging the first patch. @haampie What do you think? Untested attempt to adapt that patch for libssh2: diff --git a/configure.ac b/configure.ac
index b5a5791e..be7dd717 100644
--- a/configure.ac
+++ b/configure.ac
@@ -392,6 +392,14 @@ fi
LIBS="${LIBS} ${LTLIBZ}"
+dnl merge the pkg-config Libs.private field into Libs when static-only
+if test "x$enable_shared" = "xno"; then
+ LIBS_NO_SHARED=$LIBS
+else
+ LIBS_NO_SHARED=
+fi
+AC_SUBST(LIBS_NO_SHARED)
+
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile
diff --git a/libssh2.pc.in b/libssh2.pc.in
index 9cbebb7f..61b93efe 100644
--- a/libssh2.pc.in
+++ b/libssh2.pc.in
@@ -15,6 +15,6 @@ URL: https://www.libssh2.org/
Description: Library for SSH-based communication
Version: @LIBSSH2VER@
Requires.private: @LIBSREQUIRED@
-Libs: -L${libdir} -lssh2
+Libs: -L${libdir} -lssh2 @LIBS_NO_SHARED@
Libs.private: @LIBS@
Cflags: -I${includedir}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8638ac41..11caa5de 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -189,6 +189,12 @@ endif()
set(LIBSSH2VER ${LIBSSH2_VERSION})
set(LIBSREQUIRED ${PC_REQUIRES_PRIVATE})
set(LIBS ${PC_LIBS})
+# merge the pkg-config Libs.private field into Libs when static-only
+if(BUILD_SHARED_LIBS)
+ set(LIBS_NO_SHARED "")
+else()
+ set(LIBS_NO_SHARED "${PC_LIBS}")
+endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") |
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 13, 2023
Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Closes #xxxx
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 13, 2023
Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes #xxxx
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 14, 2023
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 15, 2023
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 15, 2023
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
vszakats
added a commit
that referenced
this pull request
Jul 18, 2023
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 #1114 Ref: #1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes #1119
lampmanyao
pushed a commit
to lampmanyao/libssh2
that referenced
this pull request
Sep 3, 2023
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 libssh2#1114 Ref: libssh2#1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
agreppin
pushed a commit
to agreppin/libssh2
that referenced
this pull request
Jul 14, 2024
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 libssh2#1114 Ref: libssh2#1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not an autotools expert, but
LIBScontainslibssh2's own dependencies, so when doing shared linking, it makes no sense to put them underLibs: ...in the pkg-config file.Libs.privateis what you want to use for that, since during static linking you do have to provide transitive deps.What's not fixed in this PR: adding the
-Lsearch dirs when doing static linking. Apparently when openssl has its libraries in<prefix>/lib64, no-L<prefix>/lib64is added. But when it's in<prefix>/lib, it is? I guess this is a matter of custom logic in libssh2's autotools stuff, whereLIBS = -L... -lsslis used for thelibcheck (custom?), whileLDFLAGS = -L...andLIBS = -lsslis used for thelib64check (autotools internals?)