Skip to contentSkip to conversation

bindings: cxx: link using the libtool archives

PATCH In review [email protected] 2 participants 7 messages Mar 20, 2024 – Mar 21, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: cxx: link using the libtool archives

From: orbea <[email protected]>

When linking with internal dependencies that were built with libtool the most reliable method is to use the libtool archive (.la) files.

When building with slibtool it fails when it doesn't find the -lgpiod linker flag, but if libgpiod is already installed to the system it will be built using the system version instead of the newly built libraries.

Gentoo issue: https://bugs.gentoo.org/913899

---
 bindings/cxx/Makefile.am          | 2 +-
 bindings/cxx/examples/Makefile.am | 2 +-
 bindings/cxx/tests/Makefile.am    | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
bindings/cxx/Makefile.am +1 -1
index 1eafaa2..e2a89cf 100644
@@ -24,8 +24,8 @@ libgpiodcxx_la_CXXFLAGS = -Wall -Wextra -g -std=gnu++17
 libgpiodcxx_la_CXXFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/
 libgpiodcxx_la_CXXFLAGS += $(PROFILING_CFLAGS)
 libgpiodcxx_la_LDFLAGS = -version-info $(subst .,:,$(ABI_CXX_VERSION))
-libgpiodcxx_la_LDFLAGS += -lgpiod -L$(top_builddir)/lib
 libgpiodcxx_la_LDFLAGS += $(PROFILING_LDFLAGS)
+libgpiodcxx_la_LIBADD = $(top_builddir)/lib/libgpiod.la
 
 include_HEADERS = gpiod.hpp
 
bindings/cxx/examples/Makefile.am +1 -1
index 64ced20..eca4d64 100644
@@ -3,7 +3,7 @@
 
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
 
 noinst_PROGRAMS = \
 	async_watch_line_value \
bindings/cxx/tests/Makefile.am +3 -3
index 02b5b6d..4d40d33 100644
@@ -4,9 +4,9 @@
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -I$(top_srcdir)/tests/gpiosim/
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17 $(CATCH2_CFLAGS)
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
-AM_LDFLAGS += -lgpiosim -L$(top_builddir)/tests/gpiosim/
-AM_LDFLAGS += -pthread
+AM_LDFLAGS = -pthread
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
+LDADD += $(top_builddir)/tests/gpiosim/libgiosim.la
 
 noinst_PROGRAMS = gpiod-cxx-test
 
Signature · 1 line
2.43.2
#1 lore raw
Quoted 6 lines · On Wed, Mar 20, 2024 at 2:50 PM <[email protected]> wrote:

From: orbea <[email protected]>

When linking with internal dependencies that were built with libtool the most reliable method is to use the libtool archive (.la) files.

Quoted 8 lines

When building with slibtool it fails when it doesn't find the -lgpiod linker flag, but if libgpiod is already installed to the system it will be built using the system version instead of the newly built libraries.

Gentoo issue: https://bugs.gentoo.org/913899

---

Thanks,

Could you use your real name for the sake of code attribution (if we need a license change later on or whatever)?

Bart

author
#2 lore raw
Quoted 18 lines · On Wed, 20 Mar 2024 16:18:38 +0100 Bartosz Golaszewski <[email protected]> wrote:
Quoted 12 lines · On Wed, Mar 20, 2024 at 2:50 PM <[email protected]> wrote:

From: orbea <[email protected]>

When linking with internal dependencies that were built with libtool the most reliable method is to use the libtool archive (.la) files.

When building with slibtool it fails when it doesn't find the -lgpiod linker flag, but if libgpiod is already installed to the system it will be built using the system version instead of the newly built libraries.

Quoted 4 lines

Gentoo issue: https://bugs.gentoo.org/913899

---

Quoted 6 lines

Thanks,

Could you use your real name for the sake of code attribution (if we need a license change later on or whatever)?

Bart

If its possible I would really prefer to not, my change is trivial and I do not think it is significant enough to claim copyright.

So that I could easily link to it in the Gentoo issue I also made an github PR which is gpg signed if that helps?

https://github.com/brgl/libgpiod/pull/65

#3 lore raw
Quoted 9 lines · orbea
Quoted 8 lines

Thanks,

Could you use your real name for the sake of code attribution (if we need a license change later on or whatever)?

Bart

Quoted 7 lines

If its possible I would really prefer to not, my change is trivial and I do not think it is significant enough to claim copyright.

So that I could easily link to it in the Gentoo issue I also made an github PR which is gpg signed if that helps?

https://github.com/brgl/libgpiod/pull/65

Whatever, I guess it doesn't touch the code anyway.

Bart

#4 lore raw
In reply to [email protected]
Quoted 51 lines · On Wed, Mar 20, 2024 at 2:50 PM <[email protected]> wrote:

From: orbea <[email protected]>

When linking with internal dependencies that were built with libtool the most reliable method is to use the libtool archive (.la) files.

When building with slibtool it fails when it doesn't find the -lgpiod linker flag, but if libgpiod is already installed to the system it will be built using the system version instead of the newly built libraries.

Gentoo issue: https://bugs.gentoo.org/913899

---
 bindings/cxx/Makefile.am          | 2 +-
 bindings/cxx/examples/Makefile.am | 2 +-
 bindings/cxx/tests/Makefile.am    | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
bindings/cxx/Makefile.am +1 -1
index 1eafaa2..e2a89cf 100644
@@ -24,8 +24,8 @@ libgpiodcxx_la_CXXFLAGS = -Wall -Wextra -g -std=gnu++17
 libgpiodcxx_la_CXXFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/
 libgpiodcxx_la_CXXFLAGS += $(PROFILING_CFLAGS)
 libgpiodcxx_la_LDFLAGS = -version-info $(subst .,:,$(ABI_CXX_VERSION))
-libgpiodcxx_la_LDFLAGS += -lgpiod -L$(top_builddir)/lib
 libgpiodcxx_la_LDFLAGS += $(PROFILING_LDFLAGS)
+libgpiodcxx_la_LIBADD = $(top_builddir)/lib/libgpiod.la
 
 include_HEADERS = gpiod.hpp
 
bindings/cxx/examples/Makefile.am +1 -1
index 64ced20..eca4d64 100644
@@ -3,7 +3,7 @@
 
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
 
 noinst_PROGRAMS = \
        async_watch_line_value \
bindings/cxx/tests/Makefile.am +0 -0
index 02b5b6d..4d40d33 100644

bindings/cxx/tests/Makefile.am line 9

Quoted 9 lines
bindings/cxx/tests/Makefile.am +3 -3
@@ -4,9 +4,9 @@
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -I$(top_srcdir)/tests/gpiosim/
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17 $(CATCH2_CFLAGS)
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
-AM_LDFLAGS += -lgpiosim -L$(top_builddir)/tests/gpiosim/
-AM_LDFLAGS += -pthread
+AM_LDFLAGS = -pthread
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
+LDADD += $(top_builddir)/tests/gpiosim/libgiosim.la

Please test your changes, this is a typo and it doesn't build. It should have been "libgpiosim".

I fixed it up when applying.

Thanks,
Bartosz

Quoted 7 lines
bindings/cxx/tests/Makefile.am +0 -1
 noinst_PROGRAMS = gpiod-cxx-test
 
--

2.43.2

author
#5 lore raw
Quoted 67 lines · On Wed, 20 Mar 2024 17:43:46 +0100 Bartosz Golaszewski <[email protected]> wrote:
Quoted 53 lines · On Wed, Mar 20, 2024 at 2:50 PM <[email protected]> wrote:

From: orbea <[email protected]>

When linking with internal dependencies that were built with libtool the most reliable method is to use the libtool archive (.la) files.

When building with slibtool it fails when it doesn't find the -lgpiod linker flag, but if libgpiod is already installed to the system it will be built using the system version instead of the newly built libraries.

Gentoo issue: https://bugs.gentoo.org/913899

---
 bindings/cxx/Makefile.am          | 2 +-
 bindings/cxx/examples/Makefile.am | 2 +-
 bindings/cxx/tests/Makefile.am    | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
bindings/cxx/Makefile.am +0 -2
index 1eafaa2..e2a89cf 100644
@@ -24,8 +24,8 @@ libgpiodcxx_la_CXXFLAGS = -Wall -Wextra -g
-std=gnu++17 libgpiodcxx_la_CXXFLAGS += -fvisibility=hidden
-I$(top_srcdir)/include/ libgpiodcxx_la_CXXFLAGS +=

$(PROFILING_CFLAGS) libgpiodcxx_la_LDFLAGS = -version-info $(subst .,:,$(ABI_CXX_VERSION)) -libgpiodcxx_la_LDFLAGS += -lgpiod

bindings/cxx/Makefile.am +1 -1
-L$(top_builddir)/lib libgpiodcxx_la_LDFLAGS += $(PROFILING_LDFLAGS)
+libgpiodcxx_la_LIBADD = $(top_builddir)/lib/libgpiod.la
 
 include_HEADERS = gpiod.hpp
(quoted diff) +0 -0

b/bindings/cxx/examples/Makefile.am index 64ced20..eca4d64 100644

bindings/cxx/examples/Makefile.am +1 -1
@@ -3,7 +3,7 @@
 
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
 
 noinst_PROGRAMS = \
        async_watch_line_value \
(quoted diff) +0 -0

b/bindings/cxx/tests/Makefile.am index 02b5b6d..4d40d33 100644

bindings/cxx/tests/Makefile.am line 9

Quoted 9 lines
bindings/cxx/tests/Makefile.am +3 -3
@@ -4,9 +4,9 @@
 AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CXXFLAGS += -I$(top_srcdir)/tests/gpiosim/
 AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17 $(CATCH2_CFLAGS)
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
-AM_LDFLAGS += -lgpiosim -L$(top_builddir)/tests/gpiosim/
-AM_LDFLAGS += -pthread
+AM_LDFLAGS = -pthread
+LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
+LDADD += $(top_builddir)/tests/gpiosim/libgiosim.la  

Please test your changes, this is a typo and it doesn't build. It should have been "libgpiosim".

Quoted 12 lines

I fixed it up when applying.

Thanks,
Bartosz

Quoted 7 lines
bindings/cxx/tests/Makefile.am +0 -1
 noinst_PROGRAMS = gpiod-cxx-test
 
--

2.43.2

Thank you and apologies, I neglected to mention that I was having a hard time getting the tests to build because the check2 in Gentoo doesn't seem compatible with what you expect. Maybe its too new?

(Sending this twice because I forgot to CC the list)

#6 lore raw
Quoted 5 lines · orbea

Thank you and apologies, I neglected to mention that I was having a hard time getting the tests to build because the check2 in Gentoo doesn't seem compatible with what you expect. Maybe its too new?

I suppose you mean Catch2? What version does Gentoo provide?

Bart